Chr*_*ell 43 asp.net authentication web-config
所以这是场景,我有一个使用自定义身份验证和成员资格提供程序的Asp.Net应用程序,但我们需要允许完全匿名访问(即)应用程序中的特定文件夹.
在IIS管理器中,您可以设置文件夹的身份验证模式,但设置将保存在C:\Windows\System32\inetsrv\config\applicationHost.config文件中,如此处所述
为了使安装更容易,如果我可以在我的web.config中设置它会很好,但经过几次尝试后我认为这可能是不可能的.
有没有人知道呢?
非常感谢
Tim*_*wis 55
第一种方法是使用<location>配置标记修改web.config ,并<allow users="?"/>允许匿名或<allow users="*"/>全部:
<configuration>
<location path="Path/To/Public/Folder">
<system.web>
<authorization>
<allow users="?"/>
</authorization>
</system.web>
</location>
</configuration>
Run Code Online (Sandbox Code Playgroud)
如果该方法不起作用,则可以采用以下方法,该方法需要对IIS applicationHost.config进行少量修改.
首先,在C:\ Windows\System32\inetsrv\config\applicationHost.config中将anonymousAuthentication部分的overrideModeDefault从"Deny"更改为"Allow":
<section name="anonymousAuthentication" overrideModeDefault="Allow" />
Run Code Online (Sandbox Code Playgroud)
overrideMode是IIS的安全功能.如果在applicationHost.config中系统级别不允许覆盖,则无法在web.config中执行任何操作来启用它.如果您在目标系统上没有此级别的访问权限,则必须与托管服务提供商或系统管理员进行讨论.
其次,在设置overrideModeDefault="Allow"之后,您可以将以下内容放在web.config中:
<location path="Path/To/Public/Folder">
<system.webServer>
<security>
<authentication>
<anonymousAuthentication enabled="true" />
</authentication>
</security>
</system.webServer>
</location>
Run Code Online (Sandbox Code Playgroud)
Ser*_* S. 44
使用<location>配置标记,并<allow users="?"/>仅允许匿名或<allow users="*"/>全部使用:
<configuration>
<location path="Path/To/Public/Folder">
<system.web>
<authorization>
<allow users="?"/>
</authorization>
</system.web>
</location>
</configuration>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
113935 次 |
| 最近记录: |