The next generation of the Teknik Services. Written in ASP.NET. https://www.teknik.io/
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

ErrorController.cs 2.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. namespace Teknik.Areas.Error.Controllers
  9. {
  10. public class ErrorController : DefaultController
  11. {
  12. [AllowAnonymous]
  13. public ActionResult Exception(Exception exception)
  14. {
  15. ViewBag.Title = "Exception - " + Config.Title;
  16. ViewBag.Description = "Just a boring 'ol exception. Nothing to see here, move along.";
  17. if (Response != null)
  18. Response.StatusCode = 200;
  19. ErrorViewModel model = new ErrorViewModel();
  20. model.Exception = exception;
  21. return View(model);
  22. }
  23. [AllowAnonymous]
  24. public ActionResult General(Exception exception)
  25. {
  26. ViewBag.Title = "Http Exception - " + Config.Title;
  27. ViewBag.Description = "There has been a Http exception. Run!";
  28. ErrorViewModel model = new ErrorViewModel();
  29. model.Description = exception.Message;
  30. model.Exception = exception;
  31. return View(model);
  32. }
  33. [AllowAnonymous]
  34. public ActionResult Http403(Exception exception)
  35. {
  36. ViewBag.Title = "403 - " + Config.Title;
  37. ViewBag.Description = "Access Denied";
  38. ErrorViewModel model = new ErrorViewModel();
  39. model.Exception = exception;
  40. return View(model);
  41. }
  42. [AllowAnonymous]
  43. public ActionResult Http404(Exception exception)
  44. {
  45. ViewBag.Title = "404 - " + Config.Title;
  46. ViewBag.Description = "Uh Oh, can't find it!";
  47. ErrorViewModel model = new ErrorViewModel();
  48. model.Exception = exception;
  49. return View(model);
  50. }
  51. [AllowAnonymous]
  52. public ActionResult Http500(Exception exception)
  53. {
  54. ViewBag.Title = "500 - " + Config.Title;
  55. ViewBag.Description = "Something Borked";
  56. ErrorViewModel model = new ErrorViewModel();
  57. model.Exception = exception;
  58. return View(model);
  59. }
  60. }
  61. }