+ Reply to Thread
Results 1 to 2 of 2

Thread: redirect user to somepage when logged in

  1. #1
    Junior Member
    Join Date
    May 2012
    Posts
    3

    redirect user to somepage when logged in

    I want to redirect the user to a certain webpage , lets say "page.aspx" and that would only happen when user is successfully logged in.
    I have tried :
    Code:
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Login1.LoggedIn == true)
        {
            Response.Redirect("page.aspx");
        }    
    }
    But that seem not too be working and i get error underneath LoggedIn entitled : "Expression to evaluate"

  2. #2
    Junior Member
    Join Date
    May 2012
    Posts
    36
    Try checking the HttpContext instead.
    Code:
    protected void Page_Load(object sender, EventArgs e)
    {
        if (User.Identity.IsAuthenticated)
        {
            Response.Redirect("page.aspx");
        }    
    }
    And you could add this with the code above to make sure they go to page.aspx when the actual login happens.
    Code:
    protected void Login1_LoggedIn(object sender, EventArgs e)
    {
         Response.Redirect("page.aspx");
    }
    OR

    If you are using Forms Authentication just use defaultUrl="page.aspx".
    Code:
    web.config example :
    <authentication mode="Forms">
        <forms loginUrl="Login.aspx" defaultUrl="page.aspx" />
    </authentication>

+ Reply to Thread

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts