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

前端 未结 5 1543
猫巷女王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:26

    I don't believe there's a way around it that's built into the framework. The actual construction of the URL happens in the System.Web.Routing.ParsedRoute.Bind method and there aren't any conditions used to prevent the escaping.

    Looks like an extension method is the way to go but one that is slightly more robust than the one mentioned previously.

提交回复
热议问题