gpt4 book ai didi

iis - IIS 中的 Asp.Net 核心 MVC 应用程序 Windows 身份验证

转载 作者:行者123 更新时间:2023-12-04 03:25:57 25 4
gpt4 key购买 nike

我的 Asp.Net Core mvc Web 应用程序需要 Windows 身份验证。在开发中,在 IIS Express 上,由于此设置,一切正常

launchSettings.json

 "iisSettings": {
"windowsAuthentication": true,
"anonymousAuthentication": false,
"iisExpress": {
"applicationUrl": "http://localhost:61545/",
"sslPort": 0
}
}

部署到 IIS 时,我得到一个空白页面。对我网站的请求收到 500 错误代码。

我尝试将此配置添加到 Startup.cs,如 here 所述, 没有成功。
    services.Configure<IISOptions>(options => {
options.ForwardWindowsAuthentication = true;
});

当我直接在 IIS 中查看身份验证参数时,Windows 身份验证被激活。

我发现一些帖子讨论了一个名为 Microsoft.AspNetCore.Server.WebListener 的包。 ,其他关于实现自定义中间件。我无法想象这个基本功能需要那么多努力才能工作。我错过了什么吗?

最佳答案

launchSettings.json文件仅供VS使用。当您发布应用程序(或在没有 VS 的情况下运行)时 launchSettings.json没有被使用。当您使用 IIS/IISExpress 运行时,您只需要确保您的 web.config 具有正确的设置。在你的情况下 forwardWindowsAuthToken web.config 中的属性丢失或设置为 false .它必须设置为 true使 Windows 身份验证正常工作。发布前的示例 web.config 如下所示:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified"/>
</handlers>
<aspNetCore processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="true"/>
</system.webServer>
</configuration>

关于iis - IIS 中的 Asp.Net 核心 MVC 应用程序 Windows 身份验证,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39084052/

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