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);
}
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.
Member
1 Points
12 Posts
login check before entering a web page
Apr 15, 2010 02:15 PM|mkh786|LINK
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
Contributor
5533 Points
1510 Posts
Re: login check before entering a web page
Apr 15, 2010 02:22 PM|N_EvilScott|LINK
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");
}
Member
130 Points
46 Posts
Re: login check before entering a web page
Apr 15, 2010 02:27 PM|amtprajapati|LINK
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.
Thanks
Amit prajapati(India)
Contributor
6874 Points
1980 Posts
Re: login check before entering a web page
Apr 15, 2010 02:48 PM|RichardY|LINK
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.
Member
1 Points
12 Posts
Re: login check before entering a web page
Apr 16, 2010 08:02 AM|mkh786|LINK
Thnak You all for great feedback - God Bless!!