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.

44 lines
1.3 KiB

11 years ago
11 years ago
  1. using Elmah;
  2. using Sevomin.Models;
  3. using Sevomin.WebFrontend.Controllers;
  4. using System.Web;
  5. using System.Web.Mvc;
  6. using System.Web.Routing;
  7. namespace Sevomin.WebFrontend
  8. {
  9. public class MvcApplication : System.Web.HttpApplication
  10. {
  11. protected void Application_Start()
  12. {
  13. AreaRegistration.RegisterAllAreas();
  14. RouteConfig.RegisterRoutes(RouteTable.Routes);
  15. }
  16. void ErrorLog_Filtering(object sender, ExceptionFilterEventArgs e)
  17. {
  18. if ((e.Exception.GetBaseException() is HttpException
  19. && ((HttpException)(e.Exception.GetBaseException())).GetHttpCode() == 404
  20. && e.Context is HttpContext)
  21. || ((HttpContext)e.Context).Request.Url.ToString().ToLower().Contains(@"favicon.ico".ToLower()))
  22. {
  23. e.Dismiss();
  24. }
  25. }
  26. protected void Application_EndRequest()
  27. {
  28. if (Context.Response.StatusCode == 404)
  29. {
  30. Response.Clear();
  31. var rd = new RouteData();
  32. rd.Values["controller"] = "Base";
  33. rd.Values["action"] = "Error404";
  34. IController c = new BaseController();
  35. c.Execute(new RequestContext(new HttpContextWrapper(Context), rd));
  36. }
  37. }
  38. }
  39. }