将路径 _vti_bin/Lists.asmx 添加到 ASP.NET MVC 2 Web 应用程序
我正在尝试将路径 /_vti_bin/Lists.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 中可能吗?我是否需要将 Lists.asmx ASPX Web 服务文件添加到项目的特定位置(我无法在 Visual Studio 项目中创建 _vti_bin 文件夹)?
更新:达林的响应启用了http://localhost:8888/_vti_bin/Lists。 asmx 现在可以工作(唯一的区别是路由定义的顺序)。但现在,请求默认 MVC 2 项目站点的“关于”页面会导致请求 http://localhost:8888/_vti_bin/Lists.asmx?action=About&controller=Home,不是到家庭控制器!
显然,定义路由的顺序很重要。
I am trying to add the path /_vti_bin/Lists.asmx to my ASP.NET MVC 2 web application.
I am registering the route as follows:
routes.IgnoreRoute("{resource}.asmx/{*pathInfo}");
routes.Add(new Route("_vti_bin/Lists.asmx", new ListsHandler()));
where ListHandler is defined as:
public sealed class ListsHandler : IRouteHandler
{
#region IRouteHandler Members
public IHttpHandler GetHttpHandler(RequestContext requestContext)
{
throw new NotImplementedException();
}
#endregion
}
But when I start the MVC application and try to navigate to http://localhost:8888/_vti_bin/Lists.asmx, I get an HTTP 404 error, rather than an exception raised.
Is this even possible in MVC? Do I need to add an Lists.asmx ASPX web service file to my project in a particular place (I cannot create the _vti_bin folder in the Visual Studio project)?
Update: Darin's response enabled http://localhost:8888/_vti_bin/Lists.asmx to work now (the only difference is the order of the route definitions). But now, requesting the 'About' page of the default MVC 2 project site results in a request to http://localhost:8888/_vti_bin/Lists.asmx?action=About&controller=Home, not to the home controller!
Apparently the order in which the routes are defined matters.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这应该有效。以下是我执行的步骤:
修改 Global.asax 如下所示:
启动应用程序并导航到 http://localhost:1505/_vti_bin/Lists.asmx
This should work. Here are the steps I did:
Modify Global.asax to look like this:
Start the application and navigate to http://localhost:1505/_vti_bin/Lists.asmx