0

Currently I am getting error pages like this:

Server Error in '/' Application.
The partial view 'obj' was not found or no view engine supports the searched locations. The following locations were searched:

Is there a way that I can just return a plain error page to my users when my code has a problem?

MIMI
  • 623
  • 2
  • 9
  • 13

4 Answers4

1

You can define an error page in your web.config

http://www.aspdev.org/articles/web.config/

daniel.herken
  • 1,095
  • 7
  • 19
1

You should add [HandleError] attribute on top of your controller class. In your web.config add or change <customErrors> to <customErrors mode="on" />.

Also, here is a great article about different filters in MVC. One of the attributes covered is HandleError and it shows how to show your users plain text error messages.

http://blogs.msdn.com/b/gduthie/archive/2011/03/17/get-to-know-action-filters-in-asp-net-mvc-3-using-handleerror.aspx

Regards,

Huske

Huske
  • 9,186
  • 2
  • 36
  • 53
0

Following links will give you valuable insight on using custom error pages in asp.net mvc
ASP.NET MVC HandleError
ASP.NET MVC 404 Error Handling

Community
  • 1
  • 1
Muhammad Adeel Zahid
  • 17,474
  • 14
  • 90
  • 155
0

1.You can use OnError method in global.asax

2.You can use ErrorHandler attribute and put it on controller or action.

3.You can use GlobalFilters to add error handling to all controllers. This is recommended way and alternative to global.asax

4.You can configure error handling in web.config.

Jack Spektor
  • 1,097
  • 1
  • 11
  • 30