locked
XML RSS feed output looks blank RRS feed

  • Question

  • User208737660 posted

    Hi all, I have written the below code to convert my data into XML format but i am facing problem with it. It Displayes blank with just RSS feed Design in Firefox,IE,Safari and in chrome it displays XMLoutput. How can i modify the code to show output in those browsers? Here is the code and screenshots appended.

    aspx.cs

    using System;
    using System.Data;
    using System.Data.SqlClient;
    using System.Text;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Xml;
    using System.IO;
    //using System.Text;
    using System.Configuration;
    
    
    namespace ImplementingRss
    {
        public partial class RssFeeds : System.Web.UI.Page
        {
            SqlConnection Con = new SqlConnection(ConfigurationManager.ConnectionStrings["EPiServerDB"].ToString());
            DataTable dt;
            SqlDataAdapter sda;
    
            public void Page_Load(object sender, EventArgs e)
            {
                dt = new DataTable();
                string strQuery = "SELECT state,city,Name,ContactDetails FROM dbFujiCMSVS10_V2.dbo.tbl_DCCollectionCenter";            
                Con.Open();
                sda = new SqlDataAdapter(strQuery, Con);
                sda.Fill(dt);
    
                if (dt.Rows.Count > 1)
                {
                    Response.Clear();
                    Response.ContentType = "text/xml";
    
    
                    XmlTextWriter TextWriter = new XmlTextWriter(Response.OutputStream, Encoding.UTF8);
                    TextWriter.WriteStartDocument();
                    TextWriter.WriteStartElement("rss");
                    TextWriter.WriteAttributeString("version", "2.0");
                    TextWriter.WriteStartElement("channel");
                    
                    foreach (DataRow dr in dt.Rows)
                    {
                        TextWriter.WriteStartElement("item");
                        TextWriter.WriteElementString("State",dr.ItemArray[0].ToString());
                        TextWriter.WriteElementString("City", dr.ItemArray[1].ToString());
                        TextWriter.WriteElementString("Name", dr.ItemArray[2].ToString());
                        TextWriter.WriteElementString("ContactDetails", dr.ItemArray[3].ToString());
                        TextWriter.WriteEndElement();
                    }
    
                    
                    TextWriter.WriteEndElement();
                    TextWriter.WriteEndElement();
                    TextWriter.WriteEndDocument();
                    TextWriter.Flush();
                    TextWriter.Close();
                    Response.End();
                }
            }
        }
    }
    

    aspx

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="RssFeeds.aspx.cs" Inherits="ImplementingRss.RssFeeds" %>
    <%@ OutputCache Duration="120" VaryByParam="none" %>

    In Chrome

    In firefox

    I am not sure whether pics will be visible or not. But, Please help me out with the solution.


     

    Thursday, February 6, 2014 1:51 AM

Answers

  • User1508394307 posted

    This is a browser behavior. Firefox assumes you want to subscribe to rss and shows that subscribe page. If you want to make sure that firefox has got correct feed, then add 

    "view-source:" in the address bar before the feed address, like this:

    view-source:http://localhost:53007/RssFeeds.aspx

    http://css-tricks.com/snippets/html/view-source-of-rss-feed-in-firefox/

    Hope this helps.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, February 6, 2014 3:25 AM