The next generation of the Teknik Services. Written in ASP.NET. Fork for blog tags.
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

ErrorController.cs 3.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Web.Mvc;
  6. using Teknik.Areas.Error.ViewModels;
  7. using Teknik.Controllers;
  8. using Teknik.Filters;
  9. namespace Teknik.Areas.Error.Controllers
  10. {
  11. public class ErrorController : DefaultController
  12. {
  13. [TrackPageView]
  14. [AllowAnonymous]
  15. public ActionResult Exception(Exception exception)
  16. {
  17. ViewBag.Title = "Exception - " + Config.Title;
  18. ViewBag.Description = "Just a boring 'ol exception. Nothing to see here, move along.";
  19. if (Response != null)
  20. {
  21. Response.StatusCode = 500;
  22. Response.TrySkipIisCustomErrors = true;
  23. }
  24. ErrorViewModel model = new ErrorViewModel();
  25. model.Exception = exception;
  26. return View(model);
  27. }
  28. [TrackPageView]
  29. [AllowAnonymous]
  30. public ActionResult General(Exception exception)
  31. {
  32. ViewBag.Title = "Http Exception - " + Config.Title;
  33. ViewBag.Description = "There has been a Http exception. Run!";
  34. if (Response != null)
  35. {
  36. Response.StatusCode = 500;
  37. Response.TrySkipIisCustomErrors = true;
  38. }
  39. ErrorViewModel model = new ErrorViewModel();
  40. model.Description = exception.Message;
  41. model.Exception = exception;
  42. return View(model);
  43. }
  44. [TrackPageView]
  45. [AllowAnonymous]
  46. public ActionResult Http403(Exception exception)
  47. {
  48. ViewBag.Title = "403 - " + Config.Title;
  49. ViewBag.Description = "Access Denied";
  50. if (Response != null)
  51. {
  52. Response.StatusCode = 403;
  53. Response.TrySkipIisCustomErrors = true;
  54. }
  55. ErrorViewModel model = new ErrorViewModel();
  56. model.Exception = exception;
  57. return View(model);
  58. }
  59. [TrackPageView]
  60. [AllowAnonymous]
  61. public ActionResult Http404(Exception exception)
  62. {
  63. ViewBag.Title = "404 - " + Config.Title;
  64. ViewBag.Description = "Uh Oh, can't find it!";
  65. if (Response != null)
  66. {
  67. Response.StatusCode = 404;
  68. Response.TrySkipIisCustomErrors = true;
  69. }
  70. ErrorViewModel model = new ErrorViewModel();
  71. model.Exception = exception;
  72. return View(model);
  73. }
  74. [TrackPageView]
  75. [AllowAnonymous]
  76. public ActionResult Http500(Exception exception)
  77. {
  78. ViewBag.Title = "500 - " + Config.Title;
  79. ViewBag.Description = "Something Borked";
  80. if (Response != null)
  81. {
  82. Response.StatusCode = 500;
  83. Response.TrySkipIisCustomErrors = true;
  84. }
  85. ErrorViewModel model = new ErrorViewModel();
  86. model.Exception = exception;
  87. return View(model);
  88. }
  89. }
  90. }