【发布时间】:2013-03-27 08:10:52
【问题描述】:
我正在尝试使 XML RPC 服务运行,如以下文章所示: http://www.cookcomputing.com/blog/archives/Implementing%20an%20xml-rpc-service-with-asp-net-mvc
一切都很好,除了路由。这与此 SO 问题 MVC route conflicts 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 错误。
我做错了什么?
【问题讨论】:
标签: asp.net-mvc asp.net-mvc-4 xml-rpc