C# ASP.NET网站中的RSS错误

C# ASP.NET网站中的RSS错误,c#,asp.net,xml,rss,webforms,C#,Asp.net,Xml,Rss,Webforms,试图在谷歌搜索,但没有找到任何有用的解决这个问题,所以我们在这里。 有一个页面,在那里使用RSS应该提醒10个来自DB的最新消息。已使用本课程完成此任务- 看起来我做的一切都是对的,但当我启动我的应用程序时-我有下一个错误,或警报,nvm: This XML file does not appear to have any style information associated with it. The document tree is shown below. <rss ver

试图在谷歌搜索,但没有找到任何有用的解决这个问题,所以我们在这里。 有一个页面,在那里使用RSS应该提醒10个来自DB的最新消息。已使用本课程完成此任务- 看起来我做的一切都是对的,但当我启动我的应用程序时-我有下一个错误,或警报,nvm:

This XML file does not appear to have any style information associated with it. The     document tree is shown below.
<rss version="2.0">
<channel>
<title>Name of the website</title>
<link>http://pudel.com</link>
<description>Short description of the site</description>
<item>
<title>Jenzyk Polski</title>
<link>http://localhost:56957/rss.aspx?ID=11</link>
<pubDate>Wed, 03 Apr 2013 00:00:00 GMT</pubDate>
<description>Co to jest?</description>
</item>
<item>
<title>Czy mowic pana zona po Polsku?</title>
<link>http://localhost:56957/rss.aspx?ID=13</link>
<pubDate>Tue, 02 Apr 2013 00:00:00 GMT</pubDate>
<description>Tak, bardzo dobze mowic</description>
</item>
<item>
<title>Kim jestes z pochodzenia?</title>
<link>http://localhost:56957/rss.aspx?ID=12</link>
<pubDate>Tue, 02 Apr 2013 00:00:00 GMT</pubDate>
<description>Jestes Polakiem</description>
</item>
</channel>
</rss>
[/XML]
此XML文件似乎没有任何与之关联的样式信息。文档树如下所示。
网站名称
http://pudel.com
网站简介
延兹克·波尔斯基
http://localhost:56957/rss.aspx?ID=11
2013年4月3日星期三00:00:00 GMT
开玩笑?
Czy mowic pana zona po Polsku?
http://localhost:56957/rss.aspx?ID=13
2013年4月2日星期二00:00:00 GMT
Tak,bardzo dobze mowic
金·杰斯特斯·波乔泽尼亚?
http://localhost:56957/rss.aspx?ID=12
2013年4月2日星期二00:00:00 GMT
杰斯特斯波拉基姆
[/XML]
当然,这种观点不是我计划要做的。那么,问题在哪里?试图用不同的浏览器打开所有相同的。尝试将web.config中的编码从UTF-8更改为WINDOWS-1251-一切都一样

以下是rss.aspx.cs页面的代码:

 using System;
 using System.Collections;
 using System.Configuration;
 using System.Data;
 using System.Linq;
 using System.Web;
 using System.Web.Security;
 using System.Web.UI;
 using System.Web.UI.HtmlControls;
 using System.Web.UI.WebControls;
 using System.Web.UI.WebControls.WebParts;
 using System.Xml.Linq;
 using System.Data.SqlClient;

 namespace softacom.pb
{
public partial class rss : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        string connString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;

        SqlConnection sqlConn = new SqlConnection();
        sqlConn.ConnectionString = connString;

        string sqlQuery = "SELECT TOP 10 newsID, Title, Date, Description FROM News ORDER BY Date DESC";

        SqlCommand cmd = new SqlCommand();
        cmd.Connection = sqlConn;
        cmd.CommandType = CommandType.Text;
        cmd.CommandText = sqlQuery;

        sqlConn.Open();
        RepeaterRSS.DataSource = cmd.ExecuteReader();
        RepeaterRSS.DataBind();
        sqlConn.Close();

    }
    protected string RemoveIllegalCharacters(object input)
    {
        string data = input.ToString();
        data = data.Replace("&", "&amp;");
        data = data.Replace("\"", "&quot;");
        data = data.Replace("'", "&apos;");
        data = data.Replace("<", "&lt;");
        data = data.Replace(">", "&gt;");

        return data;
    }


}
 }
使用系统;
使用系统集合;
使用系统配置;
使用系统数据;
使用System.Linq;
使用System.Web;
使用System.Web.Security;
使用System.Web.UI;
使用System.Web.UI.HTMLControl;
使用System.Web.UI.WebControl;
使用System.Web.UI.WebControl.WebParts;
使用System.Xml.Linq;
使用System.Data.SqlClient;
名称空间softacom.pb
{
公共部分类rss:System.Web.UI.Page
{
受保护的无效页面加载(对象发送方、事件参数e)
{
string connString=ConfigurationManager.ConnectionString[“ConnectionString”].ConnectionString;
SqlConnection sqlConn=新的SqlConnection();
sqlConn.ConnectionString=connString;
string sqlQuery=“按日期描述从新闻订单中选择前10名新闻ID、标题、日期、描述”;
SqlCommand cmd=新的SqlCommand();
cmd.Connection=sqlConn;
cmd.CommandType=CommandType.Text;
cmd.CommandText=sqlQuery;
sqlConn.Open();
RepeaterRSS.DataSource=cmd.ExecuteReader();
RepeaterRSS.DataBind();
sqlConn.Close();
}
受保护的字符串RemoveIllegalCharacters(对象输入)
{
字符串数据=input.ToString();
数据=数据。替换(“&”、“&;”;
数据=数据。替换(“\”,“”);
数据=数据。替换(“”,“&apos;”);
数据=数据。替换(“,”);
返回数据;
}
}
}
这里是rss.ASPX

<%@ Page Language="C#" ContentType="text/xml"  AutoEventWireup="true"     CodeBehind="rss.aspx.cs" Inherits="softacom.pb.rss" %>

 <asp:Repeater ID="RepeaterRSS" runat="server">
 <HeaderTemplate>
 <rss version="2.0">
 <channel>
 <title>Name of the website</title>
 <link>http://pudel.com</link>
 <description> Short description of the site</description>
 </HeaderTemplate>
 <ItemTemplate>
 <item>
 <title><%# RemoveIllegalCharacters(DataBinder.Eval(Container.DataItem, "Title"))%>   </title>
 <link>http://localhost:56957/rss.aspx?ID=<%# DataBinder.Eval(Container.DataItem, "newsID") %></link>
 <pubDate><%# String.Format("{0:R}", DataBinder.Eval(Container.DataItem, "Date"))%>  </pubDate>  
 <description><%# RemoveIllegalCharacters(DataBinder.Eval(Container.DataItem, "Description"))%></description>  
    </item>  
    </ItemTemplate>  
    <FooterTemplate>  
            </channel>  
        </rss>    
    </FooterTemplate>  
 </asp:Repeater> 

网站名称
http://pudel.com
网站简介
http://localhost:56957/rss.aspx?ID=

“我有下一个错误或警报,nvm:[…]当然,这个视图不是我计划要做的。”-请更好地解释问题,显示预期和实际结果。好的,希望看到这样的页面:但只看到本主题中显示的第一个代码:他的XML文件似乎没有任何与之关联的样式信息。文档树如下图所示。顺便说一句,尝试在Firefox中打开它-它显示正确。但是Chrome显示了这个问题,IE什么也没有显示:)通过在Chrome中添加RSS插件,问题得到了解决。谢谢!