如何使用ASP.NET Core显示错误 [英] How to display errors with ASP.NET Core

查看:146
本文介绍了如何使用ASP.NET Core显示错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个非常简单的网站,可以使用ASP.NET Core进行游戏.我正在从命令行运行该应用程序,并且该网站正在返回静态文件,但是当我尝试发出应由MVC处理的请求时,我不断收到500个错误.我如何查看错误是什么?该错误是显示在浏览器中还是登录到控制台都没有关系,我只想知道一种错误原因即可.

I have a fairly simple website that I am playing with using ASP.NET Core. I am running the application from the command line and the website is returning static files but I keep getting 500 errors when I attempt to make a request that should get handled by MVC. How do I see what the error is? Whether the error is displayed to the browser or logged to the console doesn't matter I just want a way to see what the error is.

推荐答案

添加错误页面中间件,如图所示

Add the error page middleware as shown here:

app.UseDeveloperExceptionPage();

这篇关于如何使用ASP.NET Core显示错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆