我正在尝试使 XML RPC 服务运行,如以下文章所示:http: //www.cookcomputing.com/blog/archives/Implementing%20an%20xml-rpc-service-with-asp-net-mvc
一切都很好,除了路由。这与此 SO question MVC route conflict with service route中讨论的问题类似
我的 RegisterRoutes 代码如下所示:
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
routes.Add(new Route("wlw/publish", new WLWRouteHandler()));
}
当我把这条线
routes.Add(new Route("wlw/publish", new WLWRouteHandler()));
在 MapRoutes 之前我可以访问该服务,但我的正常路线不起作用。我尝试添加第四个参数:
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional },
constraints: new { controller = "regex-for-!=-wlw" }
);
但后来我得到一个 403 The Web server is configured to not list the contents of this directory 错误。
我究竟做错了什么?