securing web pages using forms authentication
-
i have two web pages(login.aspx and account.aspx)i want to secure my account.aspx from unauthorised access.i used forms authentication as modified the web.config as follows: in the login button click event the codes are as follows: if username.text="pradip" and password.text="pkc" then FormsAuthentication.RedirectFromLoginPage(username.text,false) else labelmsg.text="invalid user name or password" now my problem is that when ever i am directly accesing accout.aspx(without logging in),it is not automatically redirecting to login.aspx.. suoopse i have 10 webforms in my project out of which i want to make 5 web forms secure so that if any unauthorised user wants to access them,they will be automatically redirected to login.aspx ..how can i do this(i think that i have to check the cookie value "AuthCookie" in the page load event of the secure pages..but i dont know how to do it.. if i write request.cookies("AuthCookie").value is nothing then response.redirect("login.aspx").. in the page load events of the secure pages then also it is not redirecting to login.aspx..plz help me out this..its urgent .. thanks in advance
pradip kishore
-
i have two web pages(login.aspx and account.aspx)i want to secure my account.aspx from unauthorised access.i used forms authentication as modified the web.config as follows: in the login button click event the codes are as follows: if username.text="pradip" and password.text="pkc" then FormsAuthentication.RedirectFromLoginPage(username.text,false) else labelmsg.text="invalid user name or password" now my problem is that when ever i am directly accesing accout.aspx(without logging in),it is not automatically redirecting to login.aspx.. suoopse i have 10 webforms in my project out of which i want to make 5 web forms secure so that if any unauthorised user wants to access them,they will be automatically redirected to login.aspx ..how can i do this(i think that i have to check the cookie value "AuthCookie" in the page load event of the secure pages..but i dont know how to do it.. if i write request.cookies("AuthCookie").value is nothing then response.redirect("login.aspx").. in the page load events of the secure pages then also it is not redirecting to login.aspx..plz help me out this..its urgent .. thanks in advance
pradip kishore
I prefer using Session variables rather than cookies because some users disable cookies of their navigators. It's so easy to use !! 1. Authenticate event in the login page :
protected void Login1_Authenticate(object sender, AuthenticateEventArgs e) { if ((username.text="pradip") && (password.text="pkc" )) Session["Authenticated"] = "Ok"; }
2. on_Load event of every Secured page :if (Session["Authenticated"].ToString() != "Ok") RedirectToLognPage().....
The novice.
-
I prefer using Session variables rather than cookies because some users disable cookies of their navigators. It's so easy to use !! 1. Authenticate event in the login page :
protected void Login1_Authenticate(object sender, AuthenticateEventArgs e) { if ((username.text="pradip") && (password.text="pkc" )) Session["Authenticated"] = "Ok"; }
2. on_Load event of every Secured page :if (Session["Authenticated"].ToString() != "Ok") RedirectToLognPage().....
The novice.
hi novice thanks for your vital support do i have to use the forms authentication..or simple i set the cookie after the validation of the user credentials in the login form..? if i dont use the forms authentication,then how i can make the user to sign out while pressing sign out button.. please replay back soon.. thanks in advance
pradip kishore
-
hi novice thanks for your vital support do i have to use the forms authentication..or simple i set the cookie after the validation of the user credentials in the login form..? if i dont use the forms authentication,then how i can make the user to sign out while pressing sign out button.. please replay back soon.. thanks in advance
pradip kishore
-
In my example I used the authentication form of Visual Studio and its "Authenticate" event. There's no use of cookies.
The novice.
from where would i get the authenticate form..is it built in or i have to design one..if built in..will you please tell me how to incorporate it into my project..??? please reply back soon thanks in advance..
pradip kishore