如何在 vb.net 中解码一个 url
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14350192/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
how to decode a url in vb.net
提问by birddseedd
This line says server is not declared.
此行表示未声明服务器。
Dim DecodedString As String = server.UrlDecode(context.Request.Form("DeckName"))
I have imports system.web at the top. cannot seem to figure out why its not working.
我在顶部导入了 system.web。似乎无法弄清楚为什么它不起作用。
回答by
Use HttpUtilityinstead.
使用HttpUtility来代替。
Dim decodedUrl As String = HttpUtility.UrlDecode(encodedUrl)
More details here:
http://msdn.microsoft.com/en-us/library/system.web.httputility.urldecode.aspx
更多详细信息:http:
//msdn.microsoft.com/en-us/library/system.web.httputility.urldecode.aspx
回答by JakeLarson
This is old and K3N already provided a great answer.. but I believe the 's' in 'server' should be capitalized in your code. That may have been the issue.
这是旧的,K3N 已经提供了一个很好的答案..但我相信“服务器”中的“s”应该在您的代码中大写。那可能是问题所在。
回答by Noel Villareal Paguio
Imports System.Net
Dim DecodedString As String = WebUtility.UrlDecode(context.Request.Form("DeckName"))
This should work for vb.net. I tried the HttpUtility but it doesn't recognize even i imported System.Web.
这应该适用于 vb.net。我尝试了 HttpUtility,但即使我导入了 System.Web,它也无法识别。

