想问题时,路由与结束的路径'。“ [英] Issue when trying to route a path that ends with a '.'

查看:80
本文介绍了想问题时,路由与结束的路径'。“的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图路由路径是这样的:

  http://www.wikipediamaze.com/wiki/Washington,_D.​​C。

路由架构不捡这件事作为一个有效的途径,并给了我一个找不到资源错误。任何人都知道我怎样才能解决此问题?它甚至没有让我的控制器工厂,以便就好像它甚至不承认它作为一个路径或者寻找一个实际的文件。

我没有像这样类似的航线任何问题:

  http://www.wikipediamaze.com/wiki/United_States
http://www.wikipediamaze.com/wiki/Canadian_Bacon_(film)

但只要我结束与一个url'。它不进行路由。如果我这样做它的工作原理:

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

这是我设置的路线是这样的:

  routes.MapRoute(
    维基
    维基/ {}话题,
    新{控制器=游戏,行动=继续,主题=}
);


解决方案

的点是被PTED为文件扩展名的开头为跨$ P $在

  mypage.mvc或的Index.aspx

我不知道如何解决它的第一条线索,虽然形式

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

看起来非常简洁明了的给我。这种形式的工作,因为MVC自动知道一个问号将被后面一个命名参数,而不是另一部分路径。

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 = "" }
);

解决方案

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.

这篇关于想问题时,路由与结束的路径'。“的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆