且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

为什么System.Net.Http HttpClient编码我的请求URL?

更新时间:2023-01-26 08:04:44

  1. 请非常具体地回答您的问题:

  1. Please be very specific about your question:

  • 您使用Microsoft.Net.Http版本是什么?
  • 您在.NET版本下编译什么?

原来您是在.NET 4.0下编译的,这是我要说的错误,因为其行为与.NET Fx 4.5 System.Http

Turned out that you compile under .NET 4.0 and this is a bug I would say, because the behavior is not identical to the .NET Fx 4.5 System.Http

您可以通过在Uri类中将dontEscape设置为true来解决此问题:

You can fix it by setting dontEscape to true in the Uri class:

 var url = new Uri(@"http://google.com/advert?paginate=1&page=1&language=en&filters[updated_at][ge]=2016-03-21%2012:19:05", dontEscape: true);