帮助C#HttpWebRequest URI丢失其编码 [英] Help with C# HttpWebRequest URI losing its encoding
问题描述
HttpWebRequest解码我的编码URL时遇到问题.
Having a problem with HttpWebRequest decoding my encoded URL.
var requestUrl = "https://www.google.com/webmasters/tools/feeds/http%3A%2F%2Fwww%2example%2Ecom%2F/crawlissues/";
var request = (HttpWebRequest)WebRequest.Create(requestUrl);
当查看结束请求时,URL变为:
When looking at end request URL is becomes:
>://www.google.com/webmasters/tools/feeds/http://www.example.com//crawlissues/
https://www.google.com/webmasters/tools/feeds/http://www.example.com//crawlissues/
当然会返回400错误的请求.我猜想这是URI类而不是HttpWebRequest要做的事情.如何阻止这种情况发生?
Which of course returns a 400 Bad request. I am guessing it is something todo with the URI class rather than HttpWebRequest. How do I stop this from happening?
推荐答案
这是Uri类的一个令人讨厌的安全功能".如果您使用的是4.0或更高版本,则可以在您的配置文件中将其关闭;否则,您将必须重新进行反射.
This is an annoying "security feature" of the Uri class. If you're using 4.0 or later, you can turn it off in your configuration file; otherwise, you'll have to resort to reflection.
这篇关于帮助C#HttpWebRequest URI丢失其编码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!