Global.asax.cs 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Web.Mvc;
  6. using System.Web.Optimization;
  7. using System.Web.Routing;
  8. namespace M55128_rec
  9. {
  10. public class MvcApplication : System.Web.HttpApplication
  11. {
  12. protected void Application_Start()
  13. {
  14. AreaRegistration.RegisterAllAreas();
  15. FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
  16. RouteConfig.RegisterRoutes(RouteTable.Routes);
  17. }
  18. protected void Application_Error(object sender, EventArgs e)
  19. {
  20. Exception ex = Server.GetLastError();
  21. if (ex is HttpException && ((HttpException)ex).GetHttpCode() == 404)
  22. {
  23. Response.Redirect("/404");
  24. }
  25. }
  26. //protected void Application_BeginRequest(object sender, EventArgs e)
  27. //{
  28. // string oldUrl = System.Web.HttpContext.Current.Request.RawUrl;
  29. // oldUrl= oldUrl.Replace(".html","");
  30. // //var ary = oldUrl.Split('?');
  31. // //if (ary.Length > 0)
  32. // //{
  33. // // ary[0] = ary[0] + ".html";
  34. // //}
  35. // //string str = string.Join("?", ary);
  36. // Context.RewritePath(oldUrl);
  37. // //if (HttpContext.Current.Request.UserHostAddress == "192.168.1.102")
  38. // //{
  39. // // HttpContext.Current.Response.Write("这里就可以把自己电脑的IP地址屏蔽掉了。");
  40. // //}
  41. // //else
  42. // //{
  43. // // HttpContext.Current.Response.Write("");
  44. // //}
  45. //}
  46. }
  47. }