Google Chrome和IE中的RSS问题 [英] RSS Problem in Google Chrome and IE
问题描述
嗨.
我为自己的网站写了一个RSS,但浏览器出现了一些问题.
当我建立到RSS页面的链接时,谷歌浏览器不支持我的RSS和IE中的IE,第一次它什么也没显示,但是刷新后一切正常.
这是我在RSS.aspx页面中的代码:
Hi.
i wrote a RSS for my website, and i have some problem with browsers.
Google chrome didnt support my RSS and in IE when i make a link to RSS page,firstTime it shows nothing but after a refresh everything seems ok.
And here is my codebehind in RSS.aspx page :
protected void Page_Load(object sender, EventArgs e)
{
///////////////////////////////////////For RSS////////////////////////////////////////
Response.Clear();
Response.ContentType = "application/rss+xml";
XmlTextWriter objX = new XmlTextWriter(Response.OutputStream, Encoding.UTF8);
objX.WriteStartDocument();
objX.WriteStartElement("rss");
objX.WriteAttributeString("version", "2.0");
objX.WriteStartElement("channel");
SqlCommand cmd = new SqlCommand("Select Top 10 * From TNews where [lang] = 1 And [Status] = 1 And ShopID=7777 order by NewsID desc", new SqlConnection(ConfigurationManager.ConnectionStrings["ArminShopConnectionString"].ConnectionString));
cmd.Connection.Open();
SqlDataReader dr = cmd.ExecuteReader();
objX.WriteElementString("title", "Bazarsazan Last news");
objX.WriteElementString("link", "http://www.bazarsazan.com/");
objX.WriteElementString("description", "The latest news from bazarsazan.");
objX.WriteElementString("language", "en-us");
objX.WriteElementString("ttl", "60");
objX.WriteElementString("image", "http://www.bazarsazan.com/logo.gif");
objX.WriteElementString("lastBuildDate", String.Format("{0:R}", DateTime.Now));
objX.WriteElementString("copyright", "Copyright 2005 - 2011 bazarsazan.com All rights reserved.");
while (dr.Read())
{
objX.WriteStartElement("item");
objX.WriteElementString("title", dr["Title"].ToString());
objX.WriteElementString("description", dr["SmallDesc"].ToString());
objX.WriteElementString("link", "http://www.bazarsazan.com/fa/?current=news&newsrogsfaid=" + dr["NewsID"]);
objX.WriteElementString("pubDate", dr["NewsDate"].ToString());
objX.WriteEndElement();
}
objX.WriteEndElement();
objX.WriteEndElement();
objX.WriteEndDocument();
objX.Flush();
objX.Close();
Response.End();
}
Can u help me plz?
推荐答案
也许与
有关
Perhaps it has something to do with
objX.WriteElementString("pubDate", dr["NewsDate"].ToString());
数据库中的DateTime对象被强制转换为计算机/当前线程的区域性信息.
在
下
The DateTime object from the database is cast to the computer/current thread culture info.
Where under
objX.WriteElementString("lastBuildDate", String.Format("{0:R}", DateTime.Now));
您知道如何打印DateTime的格式.
试试
http://cyber.law.harvard.edu/rss/rss.html[ ^ ]
You tell how the format of the DateTime is printed.
Try
http://cyber.law.harvard.edu/rss/rss.html[^]
这篇关于Google Chrome和IE中的RSS问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!