Uri.EscapeDataString behaves different in NUnit test vs. asp.net webservice?

爷,独闯天下 提交于 2019-11-28 13:07:10

In the end, I was indeed affected by the RFC 3986 issue.

It turns out the difference is a "quirks" mode of .Net 4.5. When running in an asp.net application, unless explicitly set, .Net will attempt to maintain application compatibility with previous versions.

I stepped into framework code and found a quirk setting in UriParser. Googling led me to this article about the <httpruntime> element in web.config. Near the end, it says:

"If there is no <httpRuntime targetFramework> attribute present in Web.config, we assume that the application wanted 4.0 quirks behavior."

Once I added targetFramework="4.5" to my web.config, Uri.EscapeDataString behaved as I expected.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!