Uri
表現不同.Net4.0 VS .Net4.5如何對使用的HttpClient
var u = new Uri("http://localhost:5984/mycouchtests_pri/test%2F1");
Console.WriteLine(u.OriginalString);
Console.WriteLine(u.AbsoluteUri);
成果NET4.0解決辦法與URI和在.Net4.0 VS .Net4.5差異URL編碼
http://localhost:5984/mycouchtests_pri/test%2F1
http://localhost:5984/mycouchtests_pri/test/1
成果NET4.5
http://localhost:5984/mycouchtests_pri/test%2F1
http://localhost:5984/mycouchtests_pri/test%2F1
因此,當使用HttpClient
distributed by Microsoft via NuGet請求類似上述失敗與.Net4.0,因爲HttpRequestMessage
使用Uri
。
解決方法的任何想法?
EDIT 有一個不適用解決方法通過增加配置在<uri>
例如App.config
或Machine.config
(http://msdn.microsoft.com/en-us/library/ee656539(v=vs.110).aspx)。
<configuration>
<uri>
<schemeSettings>
<add name="http" genericUriParserOptions="DontUnescapePathDotsAndSlashes"/>
</schemeSettings>
</uri>
</configuration>
但是,由於這是一個工具庫,這不是一個真正的選擇。如果.Net4.0的HttpClient
應該與.Net4.5中的一樣,它們應該具有相同的行爲。
你可以看到'u.OriginalString'給出了相同的值,無論.net frameword如何,所以你可以只使用它,除非你真的需要另一個,糾正我,如果我錯了! – 2014-10-11 15:13:31
我無法控制。 URI在HttpClient和相關消息處理程序的黑暗地區中消耗。 – Daniel 2014-10-11 15:43:29
我想,你很關心使用'OriginalString' vs'AbsoluteUri'! ,但我仍然不清楚,因爲你需要解決方法! – 2014-10-11 15:47:44