I have implemented the code for RSS in asp.net 3.5. I can see the RSS feed in my application in Firefox.
But I couldn’t manage to load the RSS feed in Google chrome browser. It only shows the XML which I had written in my code.
How can I make my code Browser independent?
<rss version="2.0">
<channel>
<title>Demo Site</title>
<link>http://www.ABC.com</link>
<asp:repeater id="rptRss" runat="server">
<ItemTemplate>
<item>
<% if (Global.SessionData.Language == Convert.ToInt16(Global.GlobalCls.Language.Arabic))
{%>
<title>
<%# RemoveIllegalCharacters(DataBinder.Eval(Container.DataItem, "TitleAr"))%></title>
<description><%# RemoveIllegalCharacters(DataBinder.Eval(Container.DataItem, "DescriptionAr"))%></description>
<%}
else
{%>
<title>
<%# RemoveIllegalCharacters(DataBinder.Eval(Container.DataItem, "Title"))%></title>
<description><%# RemoveIllegalCharacters(DataBinder.Eval(Container.DataItem, "Description"))%></description>
<%}%>
</item>
</ItemTemplate>
</asp:repeater>
</channel>
</rss>
Here is my code behind. I have just bind the repeater and call this function to remove illegal characters.
protected string RemoveIllegalCharacters(object input)
{
// cast the input to a string
string data = input.ToString();
Cache.Remove("TitleAr");
Cache.Remove("DescriptionAr");
Cache.Remove("Title");
Cache.Remove("Description");
// replace illegal characters in XML documents with their entity references
data = data.Replace("&", "&");
data = data.Replace("\"", """);
data = data.Replace("'", "'");
data = data.Replace("<", "<");
data = data.Replace(">", ">");
return data;
}
Thanks in advance.
I have set the ContentType of the @Page directive to “text/xml” to indicate that the output of the rss.aspx page is an XML document. It’s working fine for me.