网址c#中的双引号 [英] double quotation inside url c#

查看:174
本文介绍了网址c#中的双引号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有任何方法可以让程序将我的字符串作为一个整体? 我在下面列出了一个例子 对于第二个示例,它并没有将我的整个输入作为一个完整的字符串. hotmail.com为蓝色(超链接),而id = 50被识别为字符串. 我猜它是双引号.我该怎么解决?

Is there any way to allow the program to take my string as a whole? I have listed an example below For the second example, it doesn't take my entire input as a whole string. hotmail.com is blue (hyperlink) while the id = 50 is recognised as the string. Im guessing its the double quotation marks. What can i do to solve this?

例如:

1. string str = "hi";
2. string str = "http://hotmail.com/"id"=50";

我试图声明的实际代码:

The actual code im trying to declare:

string url = @"http://www.onemap.sg/advminimap/MiniMap.htm?mWidth=700&mHeight=600&searchval=&zoomLevl=7&iwt=[{""id"":2,""x"":""{0}"",""y"":""{1}"",""screenX"":undefined,""screenY"":undefined,""infoWindowText"":""{2}"",""postalCode"":""{3}"",""searchVal"":"""",""calloutWidth"":100,""calloutHeight"":100,""calloutTitle"":""{4}"",""zoomLevel"":7}, {""id"":3,""x"":""{5}"",""y"":""{6}"",""screenX"":undefined,""screenY"":undefined,""infoWindowText"":""{7}"",""postalCode"":""{8}"",""searchVal"":"""",""calloutWidth"":100,""calloutHeight"":100,""calloutTitle"":""{9}"",""zoomLevel"":7}]&check=true&calloutTitle=&calloutWidth=100&calloutHeight=100&isEdit=1&isSearch=0";

推荐答案

始终对可能需要包含任何不寻常内容的URL部分使用url编码. 如果要加入标准,请参阅 RFC1738

Always use url encode for parts of a URL which might need to contain anything unusual.... If you want to get into the standards, refer to RFC1738

"......仅字母数字[0-9a-zA-Z],特殊字符$ -_.+!*'(), 并且可以使用用于保留目的的保留字符 URL中未编码."

"...Only alphanumerics [0-9a-zA-Z], the special characters $-_.+!*'(), and reserved characters used for their reserved purposes may be used unencoded within a URL."

要在网址中包含双引号,您需要将其编码为%22

to include double quotation inside url you need to encode it to %22

这篇关于网址c#中的双引号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆