Click here to Skip to main content
15,897,891 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
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?
Posted

1 solution

Perhaps it has something to do with
C#
objX.WriteElementString("pubDate", dr["NewsDate"].ToString());


The DateTime object from the database is cast to the computer/current thread culture info.

Where under
C#
objX.WriteElementString("lastBuildDate", String.Format("{0:R}", DateTime.Now));

You tell how the format of the DateTime is printed.

Try
http://cyber.law.harvard.edu/rss/rss.html[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900