我的地图是:
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with params
new { controller = "Home", action = "Index", id = "" } // Param defaults
);
Run Code Online (Sandbox Code Playgroud)
如果我使用URL http://localhost:5000/Home/About/100%2f200,则没有匹配的路由.我将URL更改为http://localhost:5000/Home/About/100然后再次匹配路由.
有没有简单的方法来处理包含斜杠的参数?其他转义值(空格%20)似乎有效.
编辑:
编码Base64对我有用.它使URL变得丑陋,但现在还可以.
public class UrlEncoder
{
public string URLDecode(string decode)
{
if (decode == null) return null;
if (decode.StartsWith("="))
{
return FromBase64(decode.TrimStart('='));
}
else
{
return HttpUtility.UrlDecode( decode) ;
}
}
public string UrlEncode(string encode)
{
if (encode == null) return null;
string encoded = …Run Code Online (Sandbox Code Playgroud) 每当有一个%2F十六进制代码的URL /发布到我的JBOSS服务器时,我收到一个错误:
HTTP 400 Bad Request error message.
Run Code Online (Sandbox Code Playgroud)
这是URL:
http://localhost:8080/application/**abc%2Fhi**?msg=hello"
Run Code Online (Sandbox Code Playgroud)
如果我%2F从URL中删除链接工作正常.
这%2F必须是URL的一部分,不能是请求参数.