How to leave URL parameters unescaped in ASP.NET MVC?

前端 未结 5 1566
猫巷女王i
猫巷女王i 2020-12-16 04:57

I\'ve noticed the returnurl URL parameter on the Stackoverflow login/logout links are not escaped but when I try to add path as a parameter to a route it gets escaped.

5条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-16 05:27

    How do I get it to not escape the returnurl value

    How's about this?

    var url = Url.Action("Login", "Account", new {returnurl = Request.Path});
    var unEncodedUrl = HttpUtility.UrlDecode(url);
    Response.Write("...");
    

    Be sure that's what you want though, URL encoding has its purpose.

提交回复
热议问题