注册WCF Web服务打破了我的ASP.NET HTML Web表单路由



(下面解决)
在现有的ASP .NET MVC应用程序中添加WCF Web服务时,我的登录表格会在我在应用程序启动中注册Web服务路由时通过Web服务路由登录令牌。

我的意思是,如果我不注册通往我的Web服务的路由(如下)

Protected Sub Application_Start()
       ...
       RouteTable.Routes.Add(New ServiceRoute("MyWebServiceName", New WebServiceHostFactory(), GetType(MyWebServiceName)))
       RouteConfig.RegisterRoutes(RouteTable.Routes)
       ...
End Sub 

它像这样正确地重新登录了... http://localhost:49322/Account/Login?ReturnUrl=%2F

但是,如果我确实寄存了 Web服务路由,它将尝试重新布鲁特我的登录... http://localhost:49322/EISFacialWebService?action=Login&controller=Account&ReturnUrl=%2F

有什么想法???

已解决:

我通过重构

解决了这个问题
RouteTable.Routes.Add(new ServiceRoute("MyService.svc", new ServiceHostFactory(), typeof(MyService)))

来自Globals.asax文件

进入~/App_Start/RouteConfig.vb文件...

  1. 添加了.svc扩展以忽略路线(routes.IgnoreRoute("{resource}.svc/{*pathInfo}")
  2. 在 之后添加WCF服务路由
Public Sub RegisterRoutes(ByVal routes As RouteCollection)
    routes.IgnoreRoute("{resource}.axd/{*pathInfo}")
/* [ PART 1 ] */
    routes.IgnoreRoute("{resource}.svc/{*pathInfo}")
    routes.MapRoute(
        name:="Default",
        url:="{controller}/{action}/{id}",
        defaults:=New With {.controller = "Home", .action = "Inbox", .id = UrlParameter.Optional}
    )
/* [ PART 2 ] */
    routes.Add(New ServiceRoute("MyService.svc", New WebServiceHostFactory(), GetType(MyService)))
End Sub


最新更新