.net core 网站部署后出现: An error occurred while processing your request.

An error occurred while processing your request.
Development Mode
Swapping to Development environment will display more detailed information 
about the error that occurred.
Development environment should not be enabled in deployed applications, 
as it can result in sensitive information from exceptions being displayed to end users. 
For local debugging, development environment can be enabled by 
setting the ASPNETCORE_ENVIRONMENT environment variable to Development, 
and restarting the application.

其实意思就是发生了异常, 但因为不是开发环境, 不能展示真正的错误信息给你看。

如果要看真正的错误信息, 可以将 Web.config 修改:

<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=".\Application.exe" arguments="" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="false">
      <environmentVariables>
        <environmentVariable name="ASPNETCORE_ENVIRONMENT" value="Production" />
      </environmentVariables>
    </aspNetCore>
  </system.webServer>
</configuration>

value = "Production"

修改为:

value = "Development"

重启服务(其实刷新一下页面就可以了), 再就可以看到真实的异常信息了。

不过, 真正的上线网站, 还是用日志记录异常比较好。

参考: 点击打开链接

猜你喜欢

转载自blog.csdn.net/yenange/article/details/80839367