开发者

un authenticated user must not access pages by typing in URl

开发者 https://www.devze.com 2023-03-01 07:12 出处:网络
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.

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

精彩评论

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