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.

57 lines
1.8 KiB

11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
  1. using Elmah;
  2. using FluentScheduler;
  3. using Sevomin.Models;
  4. using Sevomin.Models.Helpers;
  5. using Sevomin.WebFrontend.Controllers;
  6. using System;
  7. using System.Threading.Tasks;
  8. using System.Web;
  9. using System.Web.Mvc;
  10. using System.Web.Routing;
  11. namespace Sevomin.WebFrontend
  12. {
  13. public class MvcApplication : System.Web.HttpApplication
  14. {
  15. protected void Application_Start()
  16. {
  17. AreaRegistration.RegisterAllAreas();
  18. RouteConfig.RegisterRoutes(RouteTable.Routes);
  19. TaskManager.Initialize(new SevominRegistry());
  20. Application["ApplicationStart"] = DateTime.Now;
  21. }
  22. void ErrorLog_Filtering(object sender, ExceptionFilterEventArgs e)
  23. {
  24. if ((e.Exception.GetBaseException() is HttpException
  25. && ((HttpException)(e.Exception.GetBaseException())).GetHttpCode() == 404
  26. && e.Context is HttpContext)
  27. || ((HttpContext)e.Context).Request.Url.ToString().ToLower().Contains(@"favicon.ico".ToLower()))
  28. {
  29. e.Dismiss();
  30. }
  31. }
  32. static void TaskManager_UnobservedTaskException(Task sender, UnhandledExceptionEventArgs e)
  33. {
  34. var error = new Elmah.Error(e.ExceptionObject as Exception);
  35. Elmah.ErrorLog.GetDefault(System.Web.HttpContext.Current).Log(error);
  36. }
  37. protected void Application_EndRequest()
  38. {
  39. if (Context.Response.StatusCode == 404)
  40. {
  41. Response.Clear();
  42. var rd = new RouteData();
  43. rd.Values["controller"] = "Base";
  44. rd.Values["action"] = "Error404";
  45. IController c = new BaseController();
  46. c.Execute(new RequestContext(new HttpContextWrapper(Context), rd));
  47. }
  48. }
  49. }
  50. }