c# - un authenticated user must not access pages by typing in URl -


in web-application, authenticated user can access url localhost/mydata.aspx, un-authenticated user type url can access page. how prevent unauthorized user access page , if redirecting them login.aspx

add following in web.config file under configuration section:

<system.web>   <authorization>     <deny users="?"/>          </authorization> </system.web> 

and if want restrict access particular folder:

<location path="folderpath">     <system.web>         <authorization>             <deny users="?"/>         </authorization>     </system.web> </location> 

this allow access unauthenticate user:

<location path="loginpage.aspx">    <system.web>   <authorization>     <allow users="*"/>         </authorization> </system.web> </location> 

Comments