开发者

Shared error view in ASP.Net MVC 3, what's it for?

开发者 https://www.devze.com 2023-02-15 11:59 出处:网络
I\'m still new to MVC 3 and I\'m struggling to create a nice error page for my application. I\'ve noticed the shared Error.cshtml view which is auto generated, what\'s it used for and how ?

I'm still new to MVC 3 and I'm struggling to create a nice error page for my application.

I've noticed the shared Error.cshtml view which is auto generated, what's it used for and how ?

Any links to implementing a simple single error page would be brilliant as well :-开发者_运维技巧)


That is already in place; you just aren't seeing it as by default raw errors are displayed if your request comes from the web-server itself - very useful for debugging. Remote visitors would see the default error.cshtml result:

Sorry, an error occurred while processing your request.

To see the error page even when local, ensure the customErrors mode is "On":

<customErrors mode="On"/>

You may need to add this to <system.web> in web.config. But most commonly during debugging this is set to "RemoteOnly".

0

精彩评论

暂无评论...
验证码 换一张
取 消