我在 win 表单应用程序中有一个网络浏览器,但在打开 URL 时遇到问题。
我作为新 URL
实例传入的 URL 编码为:
/ as %2f , ? as %3f and the = as %3d
但是当我调试我的代码时,我可以看到绝对 URL
或 webbrowser.url.*
中的任何其他 URL 被解码为 / 、? 和 =。
如何保持 URL
编码?如果 URL
不是这样编码的,它将无法工作。
最佳答案
当你有一个看起来像这样的 URL
时,我找到了解决我的问题的方法:
domain.com/action/doaction/?identity=12354698789
你希望它像这样编码:
domain.com/logon?returnurl=action%2fdoaction%2f%3fidentity%3d12354698789
这在您的网络浏览器中不起作用。它将它解码为第一个 url。
我需要 doaction
Controller 中的 id
,所以我使用了这段代码:
string orgId = ControllerContext.RouteData.Values["id"].ToString();
它返回那个url,如果不确定,调试和跟踪,你会找到正确的键和值。
关于c# - WebBrowser 保持 url/uri 编码不解码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5001593/