We are designing a URL system that will specify application sections as words separated by slashes. Specifically, this is in GWT, so the relevant parts of the URL will be in the hash (which will be interpreted by a controller layer on the client-side):
http://site/gwturl#section1/section2
Run Code Online (Sandbox Code Playgroud)
Some sections may need additional attributes, which we'd like to specify with a :
, so that the section parts of the URL are unambiguous. The code would split first on /
, then on …
我已经看到IIS将冒号放入URL有问题.我也看到了其他人在这里提出的建议.
通过我正在处理的网站,我希望能够将电影,书籍等标题传递到我的网址,包含冒号,如下所示:
mysite.com/Movie/Bob:The Return
Run Code Online (Sandbox Code Playgroud)
MovieController
例如,我将把它作为一个字符串消耗掉并在线下进一步使用.
我意识到结肠不理想.有没有人有任何其他建议?与目前一样糟糕,我正在从所有冒号(:)到另一个角色进行查找和替换,然后当我想在Controller端使用它时向后替换.
为什么这个网址会在400中解决 - 错误请求?
HTTP://本地主机:2785/API /股票/ Web.App.QuotesReaders /搜索= SE%3Aabb
我的环境是Visual Studio 2010,MVC 4和使用的控制器是WebApiController.
%3A是URL编码的冒号.
解
这有一些原因:
HTTP://本地主机:2785/API /股票的className = Web.App.QuotesReaders&搜索= SE%3Aabb
...这意味着,我无法在global.asax.cs中指定此路由:
/api/ticker/{className}/{search}
Run Code Online (Sandbox Code Playgroud)
......也不是......
/api/ticker/{className}/search={search}
Run Code Online (Sandbox Code Playgroud)
... 但是这个 ...
/api/ticker
Run Code Online (Sandbox Code Playgroud)
欲了解更多信息,请访问:http://www.hanselman.com/blog/ExperimentsInWackinessAllowingPercentsAnglebracketsAndOtherNaughtyThingsInTheASPNETIISRequestURL.aspx