RouteConfig.cs 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Web.Http;
  6. using System.Web.Mvc;
  7. using System.Web.Routing;
  8. namespace PMS.WebUI
  9. {
  10. /// <summary>
  11. /// 创 建 人:王海洋
  12. /// 创建日期:2018-12-10
  13. /// 功能描述:路由配置
  14. /// </summary>
  15. public class RouteConfig
  16. {
  17. public static void RegisterRoutes(RouteCollection routes)
  18. {
  19. routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
  20. //允许加载自动义路由
  21. routes.MapMvcAttributeRoutes();
  22. //webapi路由设置
  23. routes.MapHttpRoute(
  24. name: "DefaultApi",
  25. routeTemplate: "api/{controller}/{action}/{id}",
  26. defaults: new { id = RouteParameter.Optional });
  27. //mvc路由设置
  28. routes.MapRoute(
  29. name: "Default",
  30. url: "{controller}/{action}/{id}",
  31. defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
  32. );
  33. }
  34. }
  35. }