如何创建一个不转义字符的Uri

本文关键字:转义字符 Uri 一个 何创建 创建 | 更新日期: 2023-09-27 18:02:04

我有一个调用谷歌地图WS使用签名的url。示例:http://maps.google.com/maps/api/directions/xml?origin=-22.7595196841997,-47.1268794922774&destination=-29.0062986,-49.7737413&mode=driving&waypoints=-27.2050171,-49.6415186|-27.2496772,-49.9392315|-28.0071174,-49.5894682|&sensor=false&client=gme-myClient&signature=QmH-MYSignature

但是当我呼叫:_HttpReq = (HttpWebRequest)WebRequest.Create(url);它自动将Uri转义为:http://maps.google.com/maps/api/directions/xml?origin=-22.7595196841997,-47.1268794922774&destination=-29.0062986,-49.7737413&mode=driving&waypoints=-27.2050171,-49.6415186%7C-27.2496772,-49.9392315%7C-28.0071174,-49.5894682%7C&sensor=false&client=gme-myClient&signature=QmH-P2kPs4Qt9wiQK4G0f6tH2ck=

我现在使用:_HttpReq = (HttpWebRequest)WebRequest。创建(新的Uri(这一点。url, true));

它像一个魅力,但它过时了,所以我需要如何做到这一点,而不是过时。

如何创建一个不转义字符的Uri

当您为uri使用字符串文字时,您可以在其前面放置一个@符号,如下所示:

string x = @"''''"

获取四个字符的字符串