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.

61 lines
1.8 KiB

11 years ago
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. #if !DEBUG
  20. TaskManager.Initialize(new SevominRegistry());
  21. #endif
  22. }
  23. void ErrorLog_Filtering(object sender, ExceptionFilterEventArgs e)
  24. {
  25. if ((e.Exception.GetBaseException() is HttpException
  26. && ((HttpException)(e.Exception.GetBaseException())).GetHttpCode() == 404
  27. && e.Context is HttpContext)
  28. || ((HttpContext)e.Context).Request.Url.ToString().ToLower().Contains(@"favicon.ico".ToLower()))
  29. {
  30. e.Dismiss();
  31. }
  32. }
  33. static void TaskManager_UnobservedTaskException(Task sender, UnhandledExceptionEventArgs e)
  34. {
  35. var error = new Elmah.Error(e.ExceptionObject as Exception);
  36. Elmah.ErrorLog.GetDefault(System.Web.HttpContext.Current).Log(error);
  37. }
  38. protected void Application_EndRequest()
  39. {
  40. if (Context.Response.StatusCode == 404)
  41. {
  42. Response.Clear();
  43. var rd = new RouteData();
  44. rd.Values["controller"] = "Base";
  45. rd.Values["action"] = "Error404";
  46. IController c = new BaseController();
  47. c.Execute(new RequestContext(new HttpContextWrapper(Context), rd));
  48. }
  49. }
  50. }
  51. }