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.

56 lines
1.8 KiB

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