在 .net 核心中启动应用程序时出错
Error starting application in .netcore
导航到我的 IIS 发布的 .netcore 应用程序时出现以下错误:
我已经这样设置了我的 web.config 文件:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<!--
Configure your application settings in appsettings.json. Learn more at http://go.microsoft.com/fwlink/?LinkId=786380
-->
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="dotnet" arguments=".\KritnerWebsite.dll" stdoutLogEnabled="true" stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="false" />
</system.webServer>
</configuration>
不确定此警告是否相关或只是过时了:
Severity Code Description Project File Line Source Suppression State
Warning The element 'system.webServer' has invalid child element 'aspNetCore'. List of possible elements expected: 'asp, caching, cgi, defaultDocument, directoryBrowse, globalModules, handlers, httpCompression, webSocket, httpErrors, httpLogging, httpProtocol, httpRedirect, httpTracing, isapiFilters, modules, applicationInitialization, odbcLogging, security, serverRuntime, serverSideInclude, staticContent, tracing, urlCompression, validation, management, rewrite'. KritnerWebsite D:\gitWorkspace\KritnerWebsite\src\KritnerWebsite\web.config 12 Build
web.config 中的行是根据模板,我只是将 "false" 更改为 "true" stdoutLogEnabled
。
我还在根目录中创建了一个空文件夹"logs" - 我不确定是否应该自动创建它。无论哪种方式,都没有将任何内容写入日志,所以我不确定接下来要尝试什么。
我已经在主机上的 VS2015 中打开了解决方案,编译它并通过 commandline/localhost 和 dotnet run
成功地 运行 它。这是 运行 在生产配置中使用它,因此从我的环境变量中提取见解密钥和连接字符串。所以我不确定为什么该站点可以通过 dotnet run
在我的主机上 运行 成功,但在发布到 IIS
时却不能
如何获得有关错误的更多信息?
我不确定到底是什么导致日志在 ./logs
中开始正确记录...但他们做到了。现在正在记录异常,我可以看到我在环境变量中设置的连接字符串已关闭。
仍然不确定是什么原因导致日志没有写出来,以便我更快地确定这一点。
根据 https://serverfault.com/questions/193609/make-iis-see-updated-environment-path-variable 更新我的环境变量和 运行 iisreset
后,我的网站现在可以正常使用了。
导航到我的 IIS 发布的 .netcore 应用程序时出现以下错误:
我已经这样设置了我的 web.config 文件:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<!--
Configure your application settings in appsettings.json. Learn more at http://go.microsoft.com/fwlink/?LinkId=786380
-->
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="dotnet" arguments=".\KritnerWebsite.dll" stdoutLogEnabled="true" stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="false" />
</system.webServer>
</configuration>
不确定此警告是否相关或只是过时了:
Severity Code Description Project File Line Source Suppression State Warning The element 'system.webServer' has invalid child element 'aspNetCore'. List of possible elements expected: 'asp, caching, cgi, defaultDocument, directoryBrowse, globalModules, handlers, httpCompression, webSocket, httpErrors, httpLogging, httpProtocol, httpRedirect, httpTracing, isapiFilters, modules, applicationInitialization, odbcLogging, security, serverRuntime, serverSideInclude, staticContent, tracing, urlCompression, validation, management, rewrite'. KritnerWebsite D:\gitWorkspace\KritnerWebsite\src\KritnerWebsite\web.config 12 Build
web.config 中的行是根据模板,我只是将 "false" 更改为 "true" stdoutLogEnabled
。
我还在根目录中创建了一个空文件夹"logs" - 我不确定是否应该自动创建它。无论哪种方式,都没有将任何内容写入日志,所以我不确定接下来要尝试什么。
我已经在主机上的 VS2015 中打开了解决方案,编译它并通过 commandline/localhost 和 dotnet run
成功地 运行 它。这是 运行 在生产配置中使用它,因此从我的环境变量中提取见解密钥和连接字符串。所以我不确定为什么该站点可以通过 dotnet run
在我的主机上 运行 成功,但在发布到 IIS
如何获得有关错误的更多信息?
我不确定到底是什么导致日志在 ./logs
中开始正确记录...但他们做到了。现在正在记录异常,我可以看到我在环境变量中设置的连接字符串已关闭。
仍然不确定是什么原因导致日志没有写出来,以便我更快地确定这一点。
根据 https://serverfault.com/questions/193609/make-iis-see-updated-environment-path-variable 更新我的环境变量和 运行 iisreset
后,我的网站现在可以正常使用了。