这可能是一个简单的路由问题,但在一个快速的谷歌之后,我没有点击,我做了什么错误的路由。
使用SignalR时,路由MapConnection会破坏默认的MVC路由呈现。
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.IgnoreRoute("{*favicon}", new { favicon = @"(.*/)?favicon.ico(/.*)?" });
// default MVC
routes.MapRoute("Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
);
// SignalR routing
routes.MapConnection<EventConnection>("echo", "echo/{*operation}");按照这个顺序,当SignalR js客户机连接到/echo/ url时,我将得到一个404。
如果我交换默认的MVC和SignalR路由,SignalR js客户端将正确连接到/echo/ url和SignalR函数,但是当呈现到视图时,路由会被错误地重写。
/echo?action=Index&controller=Home我漏掉了什么明显的东西吗?我在看ExclusionConstraints来排除回声路径,但这似乎很麻烦,当然还有更简单的方法吗?
此外,我尝试使用Regex违禁品,如下面的问题,但不起作用。
MVC2 Routing with WCF ServiceRoute: Html.ActionLink rendering incorrect links!
发布于 2011-09-01 01:51:21
最后,我使用下面的答案在SignalR代码中修复了这个问题,并提交了一个拉请求。
Html.ActionLink construct wrong link when a non-mvc route is added
https://stackoverflow.com/questions/7265140
复制相似问题