Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 两个不同项目中Uri构造函数(新Uri(Uri,字符串))的不同行为_C#_.net - Fatal编程技术网

C# 两个不同项目中Uri构造函数(新Uri(Uri,字符串))的不同行为

C# 两个不同项目中Uri构造函数(新Uri(Uri,字符串))的不同行为,c#,.net,C#,.net,我有两个不同的项目,它们都使用同一段代码。一个是Azure云服务网站,另一个是Windows服务。他们都调用的函数是 private static Uri ConstructUriFromUriAndString( Uri endpoint, string path) { // This is where we encode the url path to be valid string encodedPath = Http

我有两个不同的项目,它们都使用同一段代码。一个是Azure云服务网站,另一个是Windows服务。他们都调用的函数是

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);
    }
当我使用uri和编码字符串“images%2fblablabla.html”从windows服务调用此函数时,uri的AbsoluteUri属性是“uri/images/blabla.html”,我认为这是预期的行为

当我使用相同的Uri和相同的编码字符串从Azure站点调用此函数时,AbsoluteUri属性是“Uri/images&2fblablabla.html”,我后来的http请求被阻塞了

我在这两种情况下都使用了“转到定义”,并且都解析为System.dll版本2.0.0.0。windows服务使用.NET 4,Azure站点使用.NET 4.5。我不认为这是一个问题,因为它们都使用相同的System.dll程序集


如何使用相同的参数调用相同的函数并返回不同的结果?

这显然是一个已知的问题,是由.NET 4-4.5差异引起的

另见-