尝试路由以“.”结尾的路径时出现问题

发布于 2024-07-24 05:59:18 字数 657 浏览 7 评论 0原文

我正在尝试路由这样的路径:

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

熟人话多 2024-07-31 05:59:18

该点被解释为文件扩展名的开头,就像

mypage.mvc or index.aspx

我不知道如何修复它的第一个线索一样,尽管该表单

http://www.wikipediamaze.com/wiki/?topic=Washington,_D.C.

对我来说看起来非常清晰和简洁。 这种形式之所以有效,是因为 MVC 自动知道问号后面将跟着一个命名参数,而不是另一个部分路由。

The dot is being interpreted as the beginning of a file extension as in

mypage.mvc or index.aspx

I wouldn't know the first clue about how to fix it, although the form

http://www.wikipediamaze.com/wiki/?topic=Washington,_D.C.

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文