【问题标题】:.NET: understanding web.config in asp.net.NET:在 asp.net 中理解 web.config
【发布时间】:2011-02-07 00:22:28
【问题描述】:

有没有人知道一个很好的链接来解释如何使用web.config......

例如,我正在使用表单身份验证...我注意到有一个 system.web,然后它关闭了 /system.web,然后在配置下方有额外的位置标签

这里是一个例子,如果你知道有一个身份验证模式=具有授权的表单,我认为这是 ROOT ......它也包含在一个 system.web 中......在这个下面有更多 location= 带有 system.web 标签....

我从来没有真正理解我实际上在做什么.. 我已经尝试检查 MSDN 文档,但我仍然没有完全理解......

谁能帮忙?

如果您注意到我的示例......所有内容都存储在 1 个 web.config 中......我认为标准 waas 创建一个标准 web.config,然后在我希望保护的目录中创建另一个 web.config它..???

<configuration>

     <system.web>
           <compilation debug="true" strict="false" explicit="true" targetFramework="4.0" />

           <authentication mode="Forms">
        <forms loginUrl="Login.aspx" defaultUrl="Login.aspx" cookieless="UseCookies" timeout="60"/>
    </authentication>

    <authorization>
        <allow users="*"/>
    </authorization>

       </system.web>


<location path="Forms">
    <system.web>
        <authorization>
            <deny users="?"/>
            <allow users="*"/>
        </authorization>
    </system.web>
</location>
<location path="Forms/Seguridad">
    <system.web>
        <authorization>
            <allow roles="Administrador"/>
            <deny users="?"/>
        </authorization>
    </system.web>
</location>

【问题讨论】:

    标签: asp.net web-config


    【解决方案1】:

    标准条目(web.config 是可扩展的)在其中都有详细记录。

    http://msdn.microsoft.com/en-us/library/aa719558.aspx

    是一个好的开始。

    顺便说一句,这是 - 应该很明显 - 基于 XML。

    【讨论】:

      【解决方案2】:

      您可以在 Forms/Seguridad 中放置以下 web.config 文件:

      <?xml version="1.0" encoding="utf-8"?>
      <configuration>
          <system.web>
              <authorization>
                  <allow roles="Administrators" />
                  <deny users="*" />
              </authorization>
          </system.web>
      </configuration>
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2011-08-04
        • 1970-01-01
        • 2019-03-21
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多