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

查看:35
本文介绍了url 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 encode....如果您想深入了解标准,请参阅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."

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

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

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

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