开发者

WebBrowser keep url/uri encoded dont decode

I have a web-browser in a win form application and I am experiencing issues when opening a URL.

The URL I pass in as a new URL instance is encoded with:

/ as %2f , ? as %3f and the = as %3d

But when I debug my code I can see that the absolute URL or any of the 开发者_如何转开发other ones in the webbrowser.url.* is decoded as / , ? and =.

How do I keep the URL encoded? The URL will not work if It is not encoded like that.


I found a solution to my problem, when you have a URL that looks something like this:

domain.com/action/doaction/?identity=12354698789

And you want it encoded like this:

domain.com/logon?returnurl=action%2fdoaction%2f%3fidentity%3d12354698789

That does not work in your web browser. It decodes it to the first url.

I needed the id in the doaction controller so I used this code:

string orgId = ControllerContext.RouteData.Values["id"].ToString();

It returns that url, if unsure, debug and trace through, you will find the right key and value.


Why is it a problem?

If you want the undecoded URL, use the HttpRequest.RawUrl Property. The query string is automatically decoded by default and there is no public parameter that would turn it off.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜