开发者

un authenticated user must not access pages by typing in URl

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>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜