简体   繁体   English

使用Content-Disposition:attachment时XML节点被重写为小写

[英]XML nodes rewritten to lowercase when using Content-Disposition:attachment

I have two web applications that perform the same task: generating an XML file. 我有两个执行相同任务的Web应用程序:生成XML文件。 The XML nodes are mixed case and case sensitive. XML节点区分大小写。 The apps run in different environments and can't be moved. 这些应用程序在不同的环境中运行,无法移动。

I'm using Content-Disposition to send the XML string as a file download. 我正在使用Content-Disposition将XML字符串作为文件下载发送。

Web app A (C#.NET 3.5) works correctly. Web应用程序A(C#.NET 3.5)正常工作。

Web app B (C#.NET 2.0) changes the XML nodes to all lower case at the time of download. Web应用程序B(C#.NET 2.0)在下载时将XML节点更改为全部小写。 I've stepped through the code and verified that the XML string is mixed case right up until the response is sent. 我已经遍历了代码,并验证了XML字符串是否混合大小写,直到发送响应为止。

I've checked the response headers from the two servers. 我已经检查了两个服务器的响应头。 They are a bit different, but I don't see what would cause this behavior. 它们有些不同,但是我不知道会导致这种现象的原因。

A (works): A(作品):

Cache-Control:private
CacheControl:no-cache, no-store, must-revalidate
Connection:Close
Content-Disposition:attachment; filename=license.xml
Content-Length:1137
Content-Type:text/xml; charset=utf-8
Date:Mon, 28 Dec 2015 20:12:23 GMT
Expires:Thu, 01 Dec 1994 16:00:00 GMT
Pragma:no-cache
Server:ASP.NET Development Server/9.0.0.0
X-AspNet-Version:2.0.50727

B (fails): B(失败):

Cache-Control:private
Content-Disposition:attachment; filename=license.xml
Content-Length:1137
Content-Type:text/xml; charset=utf-8
Date:Mon, 28 Dec 2015 20:11:25 GMT
Server:Microsoft-IIS/5.1
X-AspNet-Version:2.0.50727
X-Powered-By:ASP.NET

It's the same code on both apps. 两个应用程序上的代码相同。 I can't find anything to explain this! 我找不到任何可以解释的东西! HELP!! 救命!!

string someXML = "<MyXML><SomeNode>Hello World</SomeNode></MyXML>";
Response.ContentType = "text/xml";
Response.AddHeader( "Content-Disposition", "attachment; filename=myfile.xml" );
Response.Write( someXML );
Response.End();

Results in an XML file with this content: 生成具有以下内容的XML文件:

<myxml><somenode>Hello World</somenode></myxml>

[UPDATE:] I removed the Content-Disposition, instead just spitting out the XML to the browser. [更新:]我删除了Content-Disposition,而是将XML吐出到浏览器中。 The .NET 2.0 STILL results in all lowercase tags. .NET 2.0 STILL生成所有小写​​标记。 So, it seems it comes down to the actually response from .NET 2.0. 因此,这似乎取决于.NET 2.0的实际响应。

[UPDATE:] I created a new .NET 2.0 web app to test this. [更新:]我创建了一个新的.NET 2.0 Web应用程序来对此进行测试。 The new app correctly sends mixed-case XML. 新应用正确发送大小写混合的XML。 There must be some setting in App B that is causing this, but I haven't found it yet. 必须在App B中进行某些设置来导致此问题,但我尚未找到它。

Check the raw response. 检查原始响应。 Perhaps they come back with different values for Content-Type? 也许他们返回了不同的Content-Type值?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM