Advertisement
Guest User

Untitled

a guest
Jul 31st, 2015
208
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.26 KB | None | 0 0
  1. @model Models.Error.ErrorPageModel
  2.  
  3. <div class="alert">
  4. <p class="">
  5. <strong>Error</strong>
  6. </p>
  7. </div>
  8.  
  9. public ActionResult Index()
  10. {
  11. ErrorPageModel model = new ErrorPageModel();
  12.  
  13. return View("Error",model);
  14. }
  15.  
  16. if (currentRouteData != null)
  17. {
  18. if (currentRouteData.Values["controller"] != null && !string.IsNullOrEmpty(currentRouteData.Values["controller"].ToString()))
  19. {
  20. currentController = currentRouteData.Values["controller"].ToString();
  21. }
  22.  
  23. if (currentRouteData.Values["action"] != null && !string.IsNullOrEmpty(currentRouteData.Values["action"].ToString()))
  24. {
  25. currentAction = currentRouteData.Values["action"].ToString();
  26. }
  27. }
  28.  
  29. httpContext.ClearError();
  30. httpContext.Response.Clear();
  31. httpContext.Response.StatusCode = exception is HttpException ? ((HttpException)exception).GetHttpCode() : 500;
  32. httpContext.Response.TrySkipIisCustomErrors = true;
  33. httpContext.Response.ContentType = "text/html";
  34.  
  35. ErrorController controller = new ErrorController();
  36. RouteData routeData = new RouteData();
  37.  
  38. routeData.Values["controller"] = "Error";
  39. routeData.Values["action"] = "Index";
  40.  
  41. controller.ViewData.Model = new ErrorPageModel();
  42. ((IController)controller).Execute(new RequestContext(new HttpContextWrapper(httpContext), routeData));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement