Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/36.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net 传递字符,如#和++;在查询字符串中?_Asp.net_Vb.net - Fatal编程技术网

Asp.net 传递字符,如#和++;在查询字符串中?

Asp.net 传递字符,如#和++;在查询字符串中?,asp.net,vb.net,Asp.net,Vb.net,我创建了一个超链接,当单击时会生成如下url: 我把它读到一个文本框中,如下所示: Me.txtTags.Text=CType(Request.QueryString(“Tag”),String) 但是这样做的结果是文本框txtTags将只包含C,而不包含++。 我试过了,但也不见了。 但是如果我看一下地址栏,这些值就在那里……试试看 Me.txtTags.Text = Server.UrlDecode(Request.QueryString("MyTag")) 无法使用“#”,因为它用于H

我创建了一个超链接,当单击时会生成如下url:

我把它读到一个文本框中,如下所示:

Me.txtTags.Text=CType(Request.QueryString(“Tag”),String)

但是这样做的结果是文本框txtTags将只包含C,而不包含++。 我试过了,但也不见了。 但是如果我看一下地址栏,这些值就在那里……

试试看

Me.txtTags.Text = Server.UrlDecode(Request.QueryString("MyTag"))

无法使用“#”,因为它用于HTML锚。虽然不知道+的确切答案,但在构建url时需要使用
UrlEncode
,在尝试读取url参数时需要使用
UrlDecode

MyURL = "http://www.contoso.com/articles.aspx?title=" & Server.UrlEncode("C#")
#
用作锚定标记,因此它不是合法的查询参数。它表示查询字符串的结尾,并分段到锚字符串的开头。我昨天自己也遇到了这个问题:)


+
通常用于对URL中的空格进行编码,因此它也不会显示在查询字符串中。

以下是查询字符串的特殊字符列表


当您使用
服务器.UrlEncode>生成链接时,应该对字符串进行编码,下面是一个示例:

MyHyperLink.NavigateUrl = "http://www.mysite.com/default.aspx?mytag=" & Server.UrlEncode("C++")
Me.txtTags.Text = Server.UrlDecode(Request.QueryString("mytag")) 'This will show "C++" without quotes in txtTags textbox.
当您试图在default.aspx中处理它时,应该使用
Server.URLDecode
对其进行解码,下面是一个示例:

MyHyperLink.NavigateUrl = "http://www.mysite.com/default.aspx?mytag=" & Server.UrlEncode("C++")
Me.txtTags.Text = Server.UrlDecode(Request.QueryString("mytag")) 'This will show "C++" without quotes in txtTags textbox.

您可能想阅读更多关于
Server.UrlEncode
Server.UrlDecode

我应该导入什么模块才能获取Server.UrlDecode?