Degeim
  •  Degeim
  • 57.2% (Neutral)
  • YAF Camper Topic Starter
2008-07-11T04:17:35Z
Hi

I have a dosomething.aspx file located in the same folder as default.aspx (which contains the forum), and I need to check that a user is logged in to the forum in this file.

Something like:

Page_load()
{
    if(yaf.NotLoggedIn)
        //Redirect to another page
}


Is that possible?
Sponsor
Degeim
  •  Degeim
  • 57.2% (Neutral)
  • YAF Camper Topic Starter
2008-07-11T12:01:32Z
I found out that I could do it this way:

using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using YAF.Classes.Utils;
using YAF.Classes.Data;

public partial class upload : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (string.IsNullOrEmpty(User.Identity.Name))
        {
            Response.Write("Log in");
        }
        else {
            Response.Write(User.Identity.Name);
        }
    }
}


Is this a good way to do it, or is there any reasons why I shouldn't do it this way?

Kindest Regards,
Degeim

About Us

The YAF.NET is an open source .NET forum project. YAF.NET is supported by an team of international developers who are build community by building community software.

Powered by Resharper Donate with PayPal button

Project Twitter Updates

Copyright © YetAnotherForum.NET & Ingo Herbote. All rights reserved