c# - 如何在默认域的 Web.config 中同时启用基本和匿名身份验证?
问题描述
我有一个在 .Net 中使用框架版本 4.6.1 开发的 Web API 应用程序,我正在尝试使用具有默认域的 web.config 文件启用基本和匿名身份验证,但它无法正常工作,任何人都可以帮助我启用使用 web.config .
我已经尝试了以下代码,但它不起作用
<system.webServer>
<security>
<basicAuthenticaion enabled="true" defaultLogonDomain="DomainName"/>
<anonymousAuthenticaion enabled="true"/>
</security>
</system.webServer>
解决方案
你应该添加一个标签,<authentication>
并且还要注意和的拼写basicAuthentication
(anonymousAuthentication
你用basicAuthenticaion
and拼写它们anonymousAuthenticaion
)。
<system.webServer>
<security>
<authentication>
<basicAuthentication enabled="true"/>
<anonymousAuthentication enabled="true"/>
</authentication>
</security>
</system.webServer>
顺便说一句,如果您启用了 Lex Li 在评论中提到的匿名身份验证,其他身份验证方法可能会关闭。因此,请检查您的要求是否需要同时启用它们。
推荐阅读
- javascript - 使用使用 inboxsdk 创建的自定义按钮发送邮件?
- windows - 如何批量使用多个参数?
- ms-access - Ms Access 记录太大 - 法语字符
- vb.net - VB.NET:DialogResult.No 没有关闭表单
- html - 如何在 CSS 课前添加批量?
- web - 如何以 URL 保持不变的方式将域指向已经存在的 heroku 应用程序
- highcharts - Highchart Bar table 工具提示在悬停工具提示时消失
- java - 为什么 OkHttpClient 连接到本地主机 127.0.0.1:28080
- bazel - Bazel 工作目录与 Maven 不同。如何迁移?
- xaml - 是 Avalonia 风格的选择器