gpt4 book ai didi

asp.net-core - 如何仅在 ASP.NET Core 子路径上使用 Windows 身份验证?

转载 作者:行者123 更新时间:2023-12-05 01:06:33 25 4
gpt4 key购买 nike

我正在尝试仅在我的 ASP.NET Core MVC 应用程序中对子路由配置 Windows 身份验证。

我的问题是当我添加时

services.AddAuthentication().AddNegotiate()

我收到一个错误

The Negotiate Authentication handler cannot be used on a server that directly supports Windows Authentication.

这导致我添加 web.config 作为文档解释:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
<location path="." inheritInChildApplications="false">
<system.webServer>
<security>
<authentication>
<anonymousAuthentication enabled="false" />
<windowsAuthentication enabled="true" />
</authentication>
</security>
</system.webServer>
</location>
</configuration>

并且错误消失了。但是,现在每个请求都会弹出 Windows 身份验证。

我尝试将位置路径更改为 .testendpoint 但这会在基本路径中引发原始错误。

那么有可能吗?我如何使只有 /testendpoint 会要求 Windows 身份验证,而应用程序的其余部分将与我在 ASP.NET Core 应用程序中配置的任何其他身份验证一起使用?

最佳答案

只是想我会分享这些信息:

首先,仅仅因为您使用 服务器管理器 安装了 Windows 身份验证,并不意味着它已启用在 IIS 中。默认情况下未启用。
您必须打开 IIS 管理器,单击您的服务器(不是网站 - 托管 IIS 的服务器计算机的名称)。然后点击Authentication - 你会看到“Windows Authentication”被禁用。启用它。现在它可以工作了。

在进行其他配置更改之前,请先检查此设置是否正确。如果 IIS 正确配置为 Windows 身份验证,则 dotNet5 和 dotNet6 的默认项目无需任何修改即可工作。

关于asp.net-core - 如何仅在 ASP.NET Core 子路径上使用 Windows 身份验证?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68916846/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com