我正在尝试添加路径
/_vti_bin/列表。asmx
对我的
ASP。NET MVC 2
web应用程序。
我登记的路线如下:
routes.IgnoreRoute("{resource}.asmx/{*pathInfo}");
routes.Add(new Route("_vti_bin/Lists.asmx", new ListsHandler()));
其中ListHandler定义为:
public sealed class ListsHandler : IRouteHandler
{
#region IRouteHandler Members
public IHttpHandler GetHttpHandler(RequestContext requestContext)
{
throw new NotImplementedException();
}
#endregion
}
但是当我启动MVC应用程序并尝试导航到
http://localhost:8888/_vti_bin/Lists.asmx
,我得到一个HTTP 404错误,而不是引发异常。
这在MVC中可能吗?我需要添加列表吗。将asmx ASPX web服务文件保存到我的项目的特定位置(我无法在Visual Studio项目中创建_vti_bin文件夹)?
更新:
达林的反应是有效的
http://localhost:8888/_vti_bin/Lists.asmx
现在开始工作(唯一的区别是路线定义的顺序)。但是现在,请求默认MVC2项目站点的“About”页面会导致请求
http://localhost:8888/_vti_bin/Lists.asmx?action=About&controller=Home
,而不是主控制器!
显然,路线的定义顺序很重要。