ASP.网网络.配置表单认证,拒绝匿名用户,允许匿名访问单个文件



我在这里阅读这个教程:http://blog.repsaj.nl/index.php/2007/08/mixing-forms-based-and-windows-authentication-in-aspnet/

这部分很有趣:

  • 创建3个文件:Loginaspx, WebLogin。aspx, WinLogin.aspx。这将是仅有的3个无需任何凭据即可访问的文件。您可以允许通过您的Web进行匿名访问。
  • 但是下面的部分是空白的:(

    所以我的问题是,我如何允许匿名访问我的登录。aspx, WebLogin。aspx和WinLogin。aspx ?

    将此添加到web.config中。您需要在每个希望每个人都可以访问的页面重复此操作(在您的情况下为3)。

        <location path="Login.aspx">
          <system.web>
            <authorization>
              <allow users="*" />
            </authorization>
          </system.web>
        </location>
    
       <configuration>
      <system.web>
        <authentication mode="Forms">
          <forms loginUrl="SignIn.aspx" defaultUrl="Welcome.aspx"  protection="All">
            <credentials passwordFormat="Clear">
              <user name="lee" password="lee12345"/>
              <user name="add" password="add12345"/>
            </credentials>
          </forms>
        </authentication>
        <authorization>
          <deny users="?" />      <!--his will restrict anonymous user access-->
        </authorization>
      </system.web>
      <location path="register.aspx">    <!--path here is path to your register.aspx page-->
        <system.web>
          <authorization>
            <allow users="*"/>       <!--this will allow access to everyone to register.aspx-->
          </authorization>
        </system.web>
      </location>
    </configuration>
    

    相关内容

    最新更新