解決 ASP.NET Core The Development environment shouldn't be enabled for deployed applications 問題

 今天發布專案後瀏覽網頁,出現了錯誤訊息



Error.

An error occurred while processing your request.

Request ID: 00-0db8ab846988d425dedca4ad62815575-d671b532783951b3-00

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.


如果想看到詳細的錯誤訊息,要網址資料夾下,打開 web.config


原始的內容長這樣


在 aspNetCore 標籤中加入

<environmentVariables>

         <environmentVariable name="ASPNETCORE_ENVIRONMENT" value="Development" />

        </environmentVariables>    

如下圖所示


儲存後重新整理網頁,就可以看到詳細的錯誤訊息囉!

{"errdesc":"A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SNI_PN11, error: 26 - Error Locating Server/Instance Specified)"}

留言

這個網誌中的熱門文章

CPE 一顆星選集題目說明與解答 - Java 筆記與心得分享

Visual Studio 自動排版格式化程式碼

1. Vito's family (CPE10406, UVA10041) - CPE一顆星解答與說明