web项目部署到本机,访问时发生异常:
Error.
An error occurred while processing your request.
Request ID: |ee4a30bd-4030df869db691a6.
Development Mode
Swapping to Development environment will display more detailed information about the error that occurred.
The Development environment shouldn't be enabled for deployed applications. It can result in displaying sensitive information from exceptions to end users. For local debugging, enable the Development environment by setting the ASPNETCORE_ENVIRONMENT environment variable to Development and restarting the app.
报错原因:
项目本身使用的.netcore 3.1框架,发布到IIS的web.config里,缺少ASPNETCORE_ENVIRONMENT的配置。
显示这个错误,意思是本身这个项目报错了,IIS认为你可以设置为开发版(Development)看到更详细的异常信息,但是你没有配置ASPNETCORE_ENVIRONMENT,所以不能认为这是开发版,需要你加上之后,才能给你显示具体异常原因。所以配置需要加上。
解法:
在IIS的web.config的<aspNetCore>节点里面,加入ASPNETCORE_ENVIRONMENT的配置,如下:
<aspNetCore processPath="dotnet" arguments=".\IndustryWeb.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="inprocess" >
<environmentVariables>
<environmentVariable name="ASPNETCORE_ENVIRONMENT" value="Development" />
</environmentVariables>
</aspNetCore>