C# IIS匿名身份验证在我将项目发布到服务器后自动打开
我的ISP.NET站点有一个奇怪的问题。我的站点使用windows身份验证,并且我已将IIS服务器上的身份验证选项设置为拒绝匿名身份验证。但是,每当我将项目上载到IIS服务器时,我的站点的匿名身份验证就会自动打开 这是我的applicationHost.config,请注意,此处的匿名身份验证设置为false,但每次我发布网站时,它都会自动更改为true,并且我必须登录到web服务器并手动将其更改回来C# IIS匿名身份验证在我将项目发布到服务器后自动打开,c#,asp.net,authentication,iis,C#,Asp.net,Authentication,Iis,我的ISP.NET站点有一个奇怪的问题。我的站点使用windows身份验证,并且我已将IIS服务器上的身份验证选项设置为拒绝匿名身份验证。但是,每当我将项目上载到IIS服务器时,我的站点的匿名身份验证就会自动打开 这是我的applicationHost.config,请注意,此处的匿名身份验证设置为false,但每次我发布网站时,它都会自动更改为true,并且我必须登录到web服务器并手动将其更改回来 <location path="[my root folder]"> &l
<location path="[my root folder]">
<system.webServer>
<security>
<authentication>
<windowsAuthentication enabled="true" />
<anonymousAuthentication enabled="false" />
<basicAuthentication enabled="false" realm="" defaultLogonDomain="[my domain]" />
</authentication>
</security>
</system.webServer>
</location>
这是我的web.config
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5" maxRequestLength="102400" executionTimeout="3600" requestLengthDiskThreshold="102400"/>
<authentication mode="Windows" />
<authorization>
<deny users="?" />
</authorization>
<customErrors mode="On" defaultRedirect="[my error page]"/>
在过去,我使用以下设置允许对一个特定子文件夹进行匿名身份验证
<location path="[my sub folder]">
<system.webServer>
<security>
<authentication>
<windowsAuthentication enabled="false" />
<anonymousAuthentication enabled="true" />
</authentication>
</security>
</system.webServer>
</location>
及
然而,我不再使用这些设置。经过几天的摸索,我终于找到了原因。事实证明,虽然我确实禁用了个人站点的匿名身份验证,但我忘记了在服务器范围内关闭匿名身份验证。如果有人犯了同样的错误,以下是我用来解决的步骤:
- 打开IIS控制面板
- 在左侧的树状视图中,选择服务器名称,而不是单个站点
- 在右侧新打开的面板中,双击IIS下的“身份验证”
- 右键单击匿名身份验证并选择禁用
<location path="[my sub folder]">
<system.web>
<authorization>
<allow users="*" />
</authorization>
</system.web>