In Visual Studio 2012 I created a new ASP.NET MVC3 Project using the Empty template. Then I created a HomeController
with the following ActionResult
:
public ActionResult Index()
{
throw new Exception("oops!");
ViewBag.Message = "hello world";
return View();
}
Next, I added a simple view for my HomeController:
@{
ViewBag.Title = "Index";
}
<h2>Index</h2>
and inserted the following in the {root}/web.config:
<customErrors mode="On"/>
Finally, I modified /Views/Shared/Error.cshtml
to look like:
@model System.Web.Mvc.HandleErrorInfo
@{
//Layout = null;
ViewBag.Title = "Error";
}
<h2>
Sorry, an error occurred while processing your request.
</h2>
When I run the project I get:
500 Internal Server Error. The website cannot display the page...
Then I decided to create another ASP.NET MVC3 Project using the Internet template. Inside the HomeController
I throw an Exception
exactly like I did above and I turned on customErrors
again in the Web.config. When I run the project I get the correct results:
Sorry, an error occurred while processing your request.
What could I be missing between the two projects?
I've went line by line through the Web.config and didn't see any differences. The Global.asax file was untouched with both projects.