开发者

ASP.NET MVC Route IDs with a period [duplicate]

This question already has answers here: Semantic urls with dots in .net (6 answers) ASP.NET MVC: How to Route Search Term with . (Period) at the end (2 answers) Closed 8 years ago开发者_StackOverflow社区.

If I have a route with the following:

{controller}/{action}/{id}

I look at the following URL:

c1/a1/abc.

It doesn't work. This only happens when the period is at the end of the URL. Any way to get ASP.NET MVC to recognize that as part of the ID?


If you are using .NET 4.0, you can set this flag in your web.config and it will be allowed:

<system.web>
    ...
    <httpRuntime relaxedUrlToFileSystemMapping="true" />
    ...
</system.web>

I've tested it and it works. Haack has an explanation of it.


Reading through the answers to the two similar problems below, I only can suggest that you encode the period before passing it to you MVC application. It looks as the period is also treated as a delimter to a rule succh as "/".

Similar problem here:

  • Semantic urls with dots in .net
  • ASP.NET MVC: How to Route Search Term with . (Period) at the end
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜