Posts

Showing posts from November, 2013

Custom Errorpage in MVC 4

Custom error in MVC 4 Source: http://thirteendaysaweek.com/2012/09/25/custom-error-page-with-asp-net-mvc-4/ Add the following Application_Error method to my Global.asax: protected void Application_Error ( object sender, EventArgs e ) { Exception exception = Server . GetLastError ( ) ; Server . ClearError ( ) ;   RouteData routeData = new RouteData ( ) ; routeData . Values . Add ( "controller" , "Error" ) ; routeData . Values . Add ( "action" , "Index" ) ; routeData . Values . Add ( "exception" , exception ) ;   if ( exception . GetType ( ) == typeof ( HttpException ) ) { routeData . Values . Add ( "statusCode" , ( ( HttpException ) exception ) . GetHttpCode ( ) ) ; } else { routeData . Values . Add ( "statusCode" , 500 ) ; }   IController controller = new ErrorController ( ) ; controller . Execute ( new Reques...