The next generation of the Teknik Services. Written in ASP.NET. https://www.teknik.io/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ErrorController.cs 1.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. Response.StatusCode = 200;
  17. ErrorViewModel model = new ErrorViewModel();
  18. model.Exception = exception;
  19. return View(model);
  20. }
  21. [AllowAnonymous]
  22. public ActionResult General(Exception exception)
  23. {
  24. ViewBag.Title = "Http Exception - " + Config.Title;
  25. Response.StatusCode = (exception as HttpException).GetHttpCode();
  26. ErrorViewModel model = new ErrorViewModel();
  27. model.Description = exception.Message;
  28. model.Exception = exception;
  29. return View(model);
  30. }
  31. [AllowAnonymous]
  32. public ActionResult Http404(Exception exception)
  33. {
  34. ViewBag.Title = "404 - " + Config.Title;
  35. ViewBag.Message = "Uh Oh, can't find it!";
  36. Response.StatusCode = 404;
  37. ErrorViewModel model = new ErrorViewModel();
  38. model.Exception = exception;
  39. return View(model);
  40. }
  41. [AllowAnonymous]
  42. public ActionResult Http500(Exception exception)
  43. {
  44. ViewBag.Title = "500 - " + Config.Title;
  45. ViewBag.Message = "Something Borked";
  46. Response.StatusCode = 500;
  47. ErrorViewModel model = new ErrorViewModel();
  48. model.Exception = exception;
  49. return View(model);
  50. }
  51. }
  52. }