简体   繁体   English

Xml 文件结果在不同浏览器上显示不一样

[英]Xml file result doesn't appear the same on different browsers

I'm using asp.net with C# ,and I've made this code for an rss page:我将 asp.net 与 C# 一起使用,并且我为 rss 页面制作了此代码:

<%@ Page Language="C#" ContentType="text/xml" AutoEventWireup="true" CodeFile="rss.aspx.cs" Inherits="rss" %>    
<asp:repeater id="RSSrepeater" runat="server">
<HeaderTemplate>  
<rss version="2.0">  
<channel>  
<title>MaGaZiNo</title>  
<link>http://localhost/Default.aspx</link>  
<description>  
MaGaZiNoOoOoOoOo
</description>  
</HeaderTemplate>  
<ItemTemplate>  
<item>
<title><%# RemoveIllegalCharacters(DataBinder.Eval(Container.DataItem, "title")) %></title>
<link>http://localhost/articles.aspx?art_id=<%# DataBinder.Eval(Container.DataItem, "articleid") %></link>  
</item>  
</ItemTemplate>  
<FooterTemplate>  
</channel>  
</rss>    
</FooterTemplate>  
</asp:repeater>

it works fine on IE ,but it gives me this message on chrome:它在 IE 上运行良好,但它在 chrome 上给了我这个消息:

This XML file does not appear to have any style information associated with it.此 XML 文件似乎没有任何与之关联的样式信息。 The document tree is shown below.文档树如下所示。

and the result looks like xml tags , I've found some similar questions ,but all are either not asp or suggested using css or xsl, is there any other solution rather than using stylesheets ?结果看起来像 xml 标签,我发现了一些类似的问题,但都不是 asp 或建议使用 css 或 xsl,是否有其他解决方案而不是使用样式表? like using some pulgins for specific browsers or something ?喜欢为特定浏览器使用一些插件吗?

This might be wrong since I'm not familiar with ASP but you have set the MIME type to text/xml .这可能是错误的,因为我不熟悉 ASP 但您已将 MIME 类型设置为text/xml I would imagine this is why Chrome displays it as XML.我想这就是 Chrome 将其显示为 XML 的原因。

For an RSS feed it should be application/rss+xml .对于 RSS 提要,它应该是application/rss+xml

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

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