RouteConfig.cs 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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.Routing;
  7. using EMIS.Utility;
  8. namespace EMIS.Web
  9. {
  10. public class RouteConfig
  11. {
  12. public static void RegisterRoutes(RouteCollection routes)
  13. {
  14. routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
  15. routes.IgnoreRoute("{resource}.zip/{*pathInfo}");
  16. routes.IgnoreRoute("{resource}.rar/{*pathInfo}");
  17. routes.IgnoreRoute("{resource}.7z/{*pathInfo}");
  18. routes.IgnoreRoute("{resource}.xls/{*pathInfo}");
  19. //routes.MapRoute(
  20. // name: "Default",
  21. // url: "{controller}/{action}/{id}",
  22. // defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
  23. //);
  24. //string[] routesArr = new string[]{
  25. // "CalendarManage","EvaluationManage"
  26. //};
  27. //foreach (string name in routesArr)
  28. //{
  29. // routes.MapRoute(
  30. // name, // 路由名称
  31. // name + "/{controller}/{action}/{id}", // 带有参数的 URL
  32. // new { controller = "Menu", action = "Index", id = UrlParameter.Optional }, // 参数默认值
  33. // namespaces: new string[] { "EMIS.Web.Controllers." + name }
  34. // );
  35. //}
  36. if (!string.IsNullOrEmpty(Const.LOCAL_SETTING_LOGIN_ACTION))
  37. {
  38. if (Const.LOCAL_SETTING_LOGIN_ACTION.ToLower() != "login")
  39. {
  40. routes.RouteExistingFiles = false;
  41. routes.MapRoute(
  42. "Login",
  43. "Account/Login/{id}",
  44. new { controller = "Account", action = Const.LOCAL_SETTING_LOGIN_ACTION, id = UrlParameter.Optional }
  45. );
  46. }
  47. }
  48. routes.MapRoute(
  49. "HTMLDefault", // Route name
  50. "{controller}/List.html", // URL with parameters
  51. new { controller = "Home", action = "List" } // Parameter defaults
  52. );
  53. //默认的路径解析
  54. routes.MapRoute(
  55. "Default", // 路由名称
  56. "{controller}/{action}/{id}", // 带有参数的 URL
  57. new { controller = "Home", action = "Index", id = UrlParameter.Optional } // 参数默认值
  58. );
  59. //aspx路径解析
  60. routes.IgnoreRoute(
  61. "ReportViewer/{webform}"
  62. );
  63. //WCF路径解析
  64. routes.IgnoreRoute(
  65. "Services/{service}"
  66. );
  67. }
  68. }
  69. }