locked
login check before entering a web page RRS feed

  • Question

  • User-50787944 posted

    In the personal website, how do we prevent user from entering (say links page) if user has not logged in the page.

     

    I am able to go to the links page without loging to the login page -

     

    Thanks

    Thursday, April 15, 2010 2:15 PM

Answers

  • User2117486576 posted

    Hi,

    If you are using the standard ASP.Net membership/roles providers, then use the ASP Configuration tool (wizard) to implement roles for your website and then create rules to allow access or restrict access to folders in your website.  This will require moving any pages that you want to protect to a separate folder.  This tool is available as an option in the Projects menu or in the toolbar at the top of the solution explorer.  You can use this tool as long as it resides on the same machine as the web site.

    Otherwise you can test for authentication in the page load event handler of an individual page as was suggested in earlier posts.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, April 15, 2010 2:48 PM

All replies

  • User-1528094326 posted

    If you are using forms authentication with the asp.net login controls then you can simply do this in the code behind.

    if (!Request.IsAuthenticated) 
    {
        Response.Redirect(~/Login.aspx");
    }

    Thursday, April 15, 2010 2:22 PM
  • User1328512288 posted

    Hi,

    Either you need to do Implement Form Authentication for Normal Authentication

    1) Form Authentication : http://www.xoc.net/works/tips/forms-authentication.asp

    2) Normal Authentication : When User loged in Store User ID in Session and check this Session Varialble value in Page bage or in Global.asax file if Session["USerID"]  is null then Rediect to login page.

    //check for User ID
    If (! (Convert.ToInt32(Sesion["UserID"]) > 0))
    {
      //rediect to login page
     Response.Redirect("login.aspx",true);
    }
    

    Thanks

    Thursday, April 15, 2010 2:27 PM
  • User2117486576 posted

    Hi,

    If you are using the standard ASP.Net membership/roles providers, then use the ASP Configuration tool (wizard) to implement roles for your website and then create rules to allow access or restrict access to folders in your website.  This will require moving any pages that you want to protect to a separate folder.  This tool is available as an option in the Projects menu or in the toolbar at the top of the solution explorer.  You can use this tool as long as it resides on the same machine as the web site.

    Otherwise you can test for authentication in the page load event handler of an individual page as was suggested in earlier posts.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, April 15, 2010 2:48 PM
  • User-50787944 posted

     

    Thnak You all for great feedback - God Bless!!

    Friday, April 16, 2010 8:02 AM