我想/_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,而不是家庭控制器!
顯然路線的定義順序是重要的。
'_vti_bin'文件夾是否是SharePoint約定?我記得看到使用SharePoint Web服務的命名約定的文件夾? (我可能完全錯了) – Ahmad 2010-04-22 06:04:18
是的,它被SharePoint使用,我實際上試圖模仿我的項目中的SharePoint服務接口。 – 2010-04-22 17:02:08