在ASP.NET 5中顯示錯誤信息


在 ASP.NET 5 中如果不進行顯示錯誤信息的相關配置,在發生錯誤時,在瀏覽器中只能看到空白頁面。

顯示錯誤信息的配置方法如下:

1)在 project.json 中添加對 Microsoft.AspNet.Diagnostics 的引用

{
    "dependencies":{
        "Microsoft.AspNet.Diagnostics": "1.0.0-*"
    }
}

2)在 Startup.cs 中添加 app.UseErrorPage() 

public class Startup
{
    public void Configure(IApplicationBuilder app)
    {
        app.UseErrorPage();
    }
}

錯誤信息顯示頁面示例:

An error occurred during the compilation of a resource required to process this request. Please review the following specific error details and modify your source code appropriately.

/Views/Shared/_Layout.cshtml

'IHtmlHelper<dynamic>' does not contain a definition for 'TabLink' and the best extension method overload 'HtmlHelperExtensions.TabLink(HtmlHelper, string, string, string)' requires a receiver of type 'HtmlHelper'


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM