2013-12-19 28 views
1

我有兩個不同的項目,它們都使用常見的一段代碼。一個是Azure Cloud Service網站,另一個是Windows服務。功能他們都調用在兩個不同的項目中Uri構造函數(新Uri(Uri,字符串))中的不同行爲

private static Uri ConstructUriFromUriAndString(
     Uri endpoint, 
     string path) 
    { 
     // This is where we encode the url path to be valid 
     string encodedPath = HttpUtility.UrlEncode(path); 
     return new Uri(endpoint, encodedPath); 
    } 

當我打電話從Windows服務這一功能與URI並在編碼字符串「圖像%2fblabla.html」,那麼URI的絕對URI屬性是「URI /圖片/布拉布拉.html「,我相信這是預期的行爲。

當我打電話從Azure的網站使用相同的URI和相同的編碼字符串中的絕對URI屬性是「URI /圖像& 2fblabla.html」,這我後來的HTTP請求哽咽此功能。

在這兩種情況下,我都使用了「Go To Definition」,並且都解析爲System.dll版本2.0.0.0。 Windows服務使用.NET 4,Azure站點使用.NET 4.5。我不認爲這是一個問題,因爲他們都使用相同的System.dll程序集。

如何用相同的參數調用相同的函數並得到不同的結果?

回答