拒绝用户访问位置路径

时间:2014-04-25 06:33:34

标签: asp.net web-config

我想拒绝此页面的所有用户,但它给了我这个错误:

<location> path attribute must be a relative virtual path.  It cannot contain any of '?' ':' '\' '*' '"' '<' '>' or '|'

这是我的web.config文件代码:

</configuration>
<location path="http://10.19.13.68/Dashboardviewer/Imv.aspx">
    <system.web>
      <authorization>
        <deny users="*"/>
      </authorization>
    </system.web>   
  </location>
</configuration> 

1 个答案:

答案 0 :(得分:2)

使用下面的代码,它可能对您有用(http://weblogs.asp.net/gurusarkar/archive/2008/09/29/setting-authorization-rules-for-a-particular-page-or-folder-in-web-config.aspx):

<configuration>    <system.web>
     <authentication mode="Forms"/>
        <authorization> <deny users="?"/>  //this will restrict anonymous user access
        </authorization>   </system.web>
     <location path="register.aspx"> **//path here is path to your register.aspx page e.g. it could be ~/publicpages/register.aspx**
    <system.web>
      <authorization>
            <allow users="*"/> // this will allow access to everyone to register.aspx
      </authorization>
    </system.web>    </location> </configuration>