将.net core 2.0网站发布到Azure或本地IIS时,发布过程会通过,但在打开我收到的网站时HTTP ERROR 500
。
要查看背后的真实错误,我将已发布网站的web.config修改为:
<aspNetCore processPath="dotnet" arguments=".\OurWebApp.dll" stdoutLogEnabled="true" stdoutLogFile=".\logs\stdout">
<environmentVariables>
<environmentVariable name="ASPNETCORE_ENVIRONMENT" value="Development" />
</environmentVariables>
</aspNetCore>
背后的错误是:
InvalidOperationException: No service for type 'Microsoft.ApplicationInsights.AspNetCore.JavaScriptSnippet' has been registered.
答案 0 :(得分:2)
解决方案是从布局页面中删除以下内容,例如_Layout.cshtml:
@inject Microsoft.ApplicationInsights.AspNetCore.JavaScriptSnippet JavaScriptSnippet
和
@Html.Raw(JavaScriptSnippet.FullScript)
然后再次发布