0

How can I pass exceptions to my custom error page and present them the same way you can on the standard error page you get when you first create a new application? The code below works on the standard error page but not on my custom. Any ideas?

@model System.Web.Mvc.HandleErrorInfo

@{
    ViewBag.Title = "Error";
}

<h1 class="error">Error.</h1>
<h2 class="error">An error occurred while processing your request.</h2>

@if (Model != null)
{
    @Model.Exception.Message
    @Model.Exception.InnerException
}
pagid
  • 13,559
  • 11
  • 78
  • 104
Misbit
  • 347
  • 2
  • 20

1 Answers1

0

you can define customError configuration in web.config here you can give path for error page.

<customErrors mode="On">
   <error code="404" path="404.html" />
</customErrors>

for more info see these links

http://ben.onfabrik.com/posts/aspnet-mvc-custom-error-pages

How to make custom error pages work in ASP.NET MVC 4

custom error page in mvc

Community
  • 1
  • 1
Akhlesh
  • 2,389
  • 1
  • 16
  • 23
  • I've already added these but I want my custom error pages to treat 500 exceptions as well. The question is how. – Misbit Feb 27 '14 at 12:08