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
-
put all the pages which you wanna have in 'Logged in ' area in configuration section of web.config as follows.
hi thanks for your response do you mean that i have to add as many location path in the web.config file as the no of secure pages i have... can you please show me how to write it for 2 web pages(account.aspx,transaction.aspx) in the web.config file thanks in advance