我的地图是:
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)