C#HttpWebRequest的GET部分连接codeD网址 [英] C# HttpWebRequest GET partially encoded url
问题描述
当我送一个开始使用HttpWebRequest的是,似乎把它变成一个URI,通过一个连接codeR运行它,并发送连接codeD字符串。当我看到我的请求地址创建后,我有一个是正确的OriginalString和绝对URI是连接codeD和不正确的。我的code和URL示例如下。
When I send a get using HttpWebRequest is seems to turn it into a uri, run it through an encoder and send the encoded string. When I look at my address in the request after it is created I have the OriginalString which is correct and an AbsoluteUri which is encoded and incorrect. My code and example urls are below.
HttpWebRequest webRequest = System.Net.WebRequest.Create(url) as HttpWebRequest;
String responseData = WebResponseGet(webRequest);
OriginalString:https://api.linkedin.com/v1/people/url=https%3A%2F%2Fwww.linkedin.com%2Fin%2Ffirstmlast\"
绝对URI:https://api.linkedin.com/v1/people/url=https%3A//www.linkedin.com/in/firstmlast\"
我怎么能强迫的HttpWebRequest送我原来的那个我通过它,而不是一个URI字符串?我也不能发送已经EN codeD字符串作为查询字符串,LinkedIn要求它分开的url。
How can I force HttpWebRequest to send my original string that I passed it and not a uri? Also I cannot send the already encoded string as a query string, LinkedIn requires it to be apart of the url.
推荐答案
我发现了一个HackedUri类此处的 http://blogs.msdn.com/b/xiangfan/archive/2012/01/16/10256915.aspx 并创造了我的要求,这样传递一个砍死URI,而不是一个字符串。这似乎是一个安全限制问题.NET。
I found a HackedUri class here: http://blogs.msdn.com/b/xiangfan/archive/2012/01/16/10256915.aspx and created my request like this passing it a "Hacked Uri" instead of a string. This seems to be a security limitation problem with .Net.
HttpWebRequest webRequest = System.Net.WebRequest.Create(HackedUri.Create(url)) as HttpWebRequest;
这篇关于C#HttpWebRequest的GET部分连接codeD网址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!