YAFLogo

Degeim
  • Degeim
  • 57.2% (Neutral)
  • YAF Camper Topic Starter
16 years ago
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
16 years ago
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