Visual Studio 配置 Azure AD 身份验证说 Windows 身份验证已配置,但未配置

Visual Studio Configure Azure AD Authentication says Windows Authentication is configured when it isn't

我想在现有 MVC 网站上配置 Azure AD 身份验证。 所以我右击Visual Studio中的网站,select"Configure Azure AD Authentication".

向导然后说:"An incompatible authentication configuration was found in this project (Windows Authentication). The wizard cannot be used to configure authentication."

它甚至将我链接到 the documentation page 解释错误。所以我从 web.config 中删除了 <authentication mode="Windows" /> 并重新构建了应用程序。但是向导一直显示此消息。

需要更改什么才能让向导继续?

身份验证助手直接在 .csproj 中检查身份验证部分和指示对 IISExpress 使用 Windows 身份验证的行:

<IISExpressWindowsAuthentication>enabled</IISExpressWindowsAuthentication>

确保删除 web.config 中的所有身份验证节点。然后卸载您的项目(在解决方案资源管理器中右键单击卸载)。编辑项目文件(右键单击,编辑,卸载后)并将 IISExpressWindowsAuthentication 标记为已禁用:

<IISExpressWindowsAuthentication>disabled</IISExpressWindowsAuthentication>

重新加载您的项目,重建然后重新打开 AD 身份验证助手。

现在应该可以了:)