尝试路由以“.”结尾的路径时出现问题
我正在尝试路由这样的路径:
http://www.wikipediamaze.com/wiki/Washington,_D.C.
路由框架没有将其视为有效路由,并给我一个“找不到资源”错误。 有人知道我该如何解决这个问题吗? 它甚至没有到达我的控制器工厂,所以就好像它甚至没有将其识别为路线或可能正在寻找实际的文件。
我对类似的路线没有任何问题,如下所示:
http://www.wikipediamaze.com/wiki/United_States
http://www.wikipediamaze.com/wiki/Canadian_Bacon_(film)
但每当我以“.”结束网址时 它不会路由它。 如果我这样做,它会起作用:
http://www.wikipediamaze.com/wiki/?topic=Washington,_D.C.
我设置的路线如下所示:
routes.MapRoute(
"wiki",
"wiki/{topic}",
new { controller = "game", action = "continue", topic = "" }
);
I'm trying to route a path like this:
http://www.wikipediamaze.com/wiki/Washington,_D.C.
The routing framework is not picking this up as a valid route and giving me a "Cannot find resource" error. Anyone know how I can get around this? It's not even getting to my controller factory so it's as if it doesn't even recognize it as a route or perhaps looking for an actual file.
I don't have any problems with similar routes like this:
http://www.wikipediamaze.com/wiki/United_States
http://www.wikipediamaze.com/wiki/Canadian_Bacon_(film)
but anytime I end a url with a '.' it doesn't route it. If I do this it works:
http://www.wikipediamaze.com/wiki/?topic=Washington,_D.C.
The route that I have setup looks like this:
routes.MapRoute(
"wiki",
"wiki/{topic}",
new { controller = "game", action = "continue", topic = "" }
);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
该点被解释为文件扩展名的开头,就像
我不知道如何修复它的第一个线索一样,尽管该表单
对我来说看起来非常清晰和简洁。 这种形式之所以有效,是因为 MVC 自动知道问号后面将跟着一个命名参数,而不是另一个部分路由。
The dot is being interpreted as the beginning of a file extension as in
I wouldn't know the first clue about how to fix it, although the form
looks very clear and concise to me. This form works because MVC automatically knows that a question mark is going to be followed by a named parameter, and not another partial route.