4
我建立了下面的代碼輸出XML:爲什麼IE不能將我的輸出識別爲XML?
public static XDocument Serialize<T>(this T source) where T : class
{
XDocument document = new XDocument();
XmlReflectionImporter xmlReflection = new XmlReflectionImporter();
XmlTypeMapping xmlMapping = xmlReflection.ImportTypeMapping(typeof(T));
XmlSerializer xmlSerializer = new XmlSerializer(xmlMapping);
using (XmlWriter xmlWriter = document.CreateWriter())
xmlSerializer.Serialize(xmlWriter, source);
return document;
}
在我的aspx頁面一個
然後,我有以下的輸出:
XDocument output = GetSomeXmlSerializedOutput();
output.Save(Response.OutputStream);
GetSomeXmlSerializedOutput()
基本上是輸出喂類擴展到Serialize擴展方法。
頁面的標題是這樣的:
<%@ Page Language="C#" CodeBehind="Alerts.aspx.cs" Inherits="Infinix.Diageo.WebApp.Get.Alerts" ContentType="text/xml" %>
火狐從剛剛將contentType輸出是XML正確假設。 IE沒有。輸出XML可供參考:
<?xml version="1.0" encoding="utf-8"?>
<ALERTS xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<ALERT>
<ID>1</ID>
<TYPE>ALERT</TYPE>
<NAME>neim</NAME>
<DETAIL>diteil</DETAIL>
<DATE>11/28/2010</DATE>
<TIME>13:50:02</TIME>
</ALERT>
<ALERT>
<ID>2</ID>
<TYPE>EVENT</TYPE>
<NAME>iven</NAME>
<DETAIL>ditel</DETAIL>
<DATE>11/28/2010</DATE>
<TIME>13:50:15</TIME>
</ALERT>
<ALERT>
<ID>3</ID>
<TYPE>BIRTHDAY</TYPE>
<NAME>pijazo</NAME>
<DETAIL>grande!</DETAIL>
<DATE>11/28/2010</DATE>
<TIME>13:50:23</TIME>
</ALERT>
</ALERTS>
爲什麼IE不能將此輸出識別爲正版XML?
`application/xml`? – khachik 2010-11-28 19:39:36