in my web-application, an authenticated user can access this URL localhos开发者_JAVA技巧t/mydata.aspx, but an un-authenticated user type this URL he can also access this page. so how to prevent unauthorized user from access this page and if they does redirecting them to login.aspx
Add the following in your web.config file under the configuration
section:
<system.web>
<authorization>
<deny users="?"/>
</authorization>
</system.web>
And if you want to restrict access to a particular folder:
<location path="FolderPath">
<system.web>
<authorization>
<deny users="?"/>
</authorization>
</system.web>
</location>
This will allow access to unauthenticate a user:
<location path="LoginPage.Aspx">
<system.web>
<authorization>
<allow users="*"/>
</authorization>
</system.web>
</location>
精彩评论