[英]Why does Uri.EscapeDataString return a different result on my CI server compared to my development machine?
On my desktop machine, I get this.. 在我的台式机上,我得到了这个。
var result = Uri.EscapeDataString("zdskjhf&*^65sdfh/.<>\\\\sdf"); // result == zdskjhf%26%2A%5E65sdfh%2F.%3C%3E%5Csdf
Now, on my CI server part of the result is NOT encoded.... I get this 现在,在我的CI服务器上,结果的一部分没有被编码。
\\\\ result == zdskjhf%26*%5E65sdfh%2F.%3C%3E%5Csdf
Notice the asterisk in the middle of the second result? 注意第二个结果中间的星号吗? in the first result, it's getting encoded.
在第一个结果中,它正在被编码。
Can anyone explain what's going on, please? 任何人都可以解释发生了什么吗?
Here's an .NET Fiddle which is using .NET 4.5 and shows the asterisk is encoded... 这是一个使用.NET 4.5 的.NET小提琴 ,它显示星号已编码...
So does this mean my machine and .NET Fiddle are both wrong ? 那么这是否意味着我的机器和 .NET Fiddle都错了 ? Or we are both right and the CI Server is wrong?
还是我们都是正确的,而CI Server是错误的?
Some diagnostic info from the build server.. 来自构建服务器的一些诊断信息。
Microsoft (R) Build Engine version 12.0.30723.0 [Microsoft .NET Framework, version 4.0.30319.34209] Copyright (C) Microsoft Corporation. All rights reserved.
(i'm not too sure how to get this info, for my local dev machine. It's win8.1 + VS 2013 Update 3.) (对于我的本地开发机器,我不太清楚如何获取此信息。它是win8.1 + VS 2013 Update3。)
All projects are .NET 4.5 ... not 4.5.1 所有项目都是.NET 4.5 ... 不是 4.5.1
I've decided to run this code on all the .NET frameworks (that matter). 我已经决定在所有.NET框架上运行此代码(很重要)。 Here's the results.
这是结果。
Data: abcde *.(.)."
.NET 2.0: abcde%20*.(.).
.NET 3.0: abcde%20*.(.).
.NET 3.5: abcde%20*.(.).
.NET 4.0: abcde%20*.(.).
-- MSDN NOTES: Bug now fixed here --
.NET 4.5: abcde%20%2A.%28.%29.
.NET 4.5.1: abcde%20%2A.%28.%29.
.NET 4.5.2: abcde%20%2A.%28.%29.
.NET 4.5.3: abcde%20%2A.%28.%29.
This then suggests that 这表明
.NET 4.5
, those values are NOT encoded. .NET 4.5
,这些值未编码。 Kewl, fine. =
.NET 4.5
those values ARE encoded.=
.NET 4.5
这些值已编码。
LINK: this is a similar SO question . 链接: 这是一个类似的SO问题 。
REF: this is the build result from the CI server which includes lots of debug info... REF: 这是CI服务器的构建结果,其中包含大量调试信息...
.NET 4.5 changed the behavior of this method. .NET 4.5更改了此方法的行为。 Search for " escape ".
搜索“ 转义 ”。
I realize this question is about different behavior on a CI system vs. a development system, but I thought I would share my finding when I had different behavior on the same box . 我意识到这个问题是关于CI系统和开发系统上不同的行为,但是我想当我在同一盒子上有不同的行为时,我会分享我的发现。
If your code is running under asp.net, just setting the project to target 4.5 and running on a machine with 4.5 or later, you may still get 4.0 behavior. 如果您的代码在asp.net下运行,只需将项目设置为目标4.5并在具有4.5或更高版本的计算机上运行,您仍可能会出现4.0行为。 You need to ensure
<httpRuntime targetFramework="4.5" />
is set in the web.config. 您需要确保在web.config中设置了
<httpRuntime targetFramework="4.5" />
。
From this blog article on msdn , 在有关msdn的博客文章中 ,
If there is no
<httpRuntime targetFramework>
attribute present in Web.config, we assume that the application wanted 4.0 quirks behavior.如果Web.config中不存在
<httpRuntime targetFramework>
属性,则假定该应用程序需要4.0的怪癖行为。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.