简体   繁体   English

与开发计算机相比,为什么Uri.EscapeDataString在CI服务器上返回不同的结果?

[英]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? 任何人都可以解释发生了什么吗?

Update 1: 更新1:

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

Update 2: 更新2:

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服务器的构建结果,其中包含大量调试信息...

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.

相关问题 Uri.EscapeDataString或HttpUtility.UrlEncode在我的情况下不起作用 - Uri.EscapeDataString or HttpUtility.UrlEncode does not work for my case Uri.EscapeDataString很奇怪 - Uri.EscapeDataString weirdness C#Uri.EscapeDatastring()等效于Java - C# Uri.EscapeDatastring() equivalent for Java Uri.EscapeDataString() 正在将 / 转换为 %2F - Uri.EscapeDataString() is converting / to %2F Uri.EscapeDataString() - 无效的 URI:Uri 字符串太长 - Uri.EscapeDataString() - Invalid URI: The Uri string is too long Uri.EscapeDataString在NUnit测试与asp.net webservice中的行为有什么不同? - Uri.EscapeDataString behaves different in NUnit test vs. asp.net webservice? 为什么我的本地化仅对我的开发机器有效? - Why does my localization only work on my Development-Machine? 通过“HttpUtility.UrlEncode”和“Uri.EscapeDataString”在 GET API 请求中编码撇号给出错误 - Encoding apostrophe in GET API request via "HttpUtility.UrlEncode" and "Uri.EscapeDataString" gives error ASP.NET Server在我的开发人员机器中显示出不同的结果? - ASP.NET Server is showing different result that in my developer machine? 为什么我的SharpSVN客户端仅返回存储库URI的一部分? - Why does my SharpSVN client return only part of the repository URI?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM