Global.asax.cs 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. using CP.Business;
  2. using CP.Common;
  3. using Newtonsoft.Json;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Linq;
  7. using System.Web;
  8. using System.Web.Http;
  9. using System.Web.Mvc;
  10. using System.Web.Optimization;
  11. using System.Web.Routing;
  12. namespace CP.Web
  13. {
  14. public class MvcApplication : System.Web.HttpApplication
  15. {
  16. protected void Application_Start()
  17. {
  18. AreaRegistration.RegisterAllAreas();
  19. RouteConfig.RegisterRoutes(RouteTable.Routes);
  20. //500 筛选器
  21. FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
  22. //日志记录
  23. LogHelper.SetConfig(new System.IO.FileInfo(AppDomain.CurrentDomain.BaseDirectory + "log4net.config"));
  24. }
  25. protected void Application_Error(object sender, EventArgs e)
  26. {
  27. //Exception lastError = Server.GetLastError();
  28. //if (lastError != null)
  29. //{
  30. // string strExceptionMessage = string.Empty;
  31. // HttpException httpError = lastError as HttpException;
  32. // if (httpError != null)
  33. // {
  34. // int httpCode = httpError.GetHttpCode();
  35. // if (httpCode == 400 || httpCode == 404)
  36. // {
  37. // Response.StatusCode = 404;
  38. // Server.ClearError();
  39. // return;
  40. // }
  41. // }
  42. // Response.StatusCode = 500;
  43. // Server.ClearError();
  44. //}
  45. }
  46. }
  47. }