2012-11-15 1 views
0

asp.net 3.5에서 RSS 용 코드를 구현했습니다. Firefox에서 내 응용 프로그램의 RSS 피드를 볼 수 있습니다.asp.net 3.5를 사용하는 Google 크롬에서 RSS가 작동하지 않습니다.

하지만 Google 크롬 브라우저에서 RSS 피드를로드 할 수 없었습니다. 그것은 단지 내 코드에서 작성한 XML을 보여줍니다.

내 코드 브라우저를 독립적으로 만들 수있는 방법은 무엇입니까?

<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> 

여기 내 코드가 있습니다. 난 그냥 리피터를 바인딩하고 불법 문자를 제거하려면이 함수를 호출합니다.

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("&", "&amp;"); 
     data = data.Replace("\"", "&quot;"); 
     data = data.Replace("'", "&apos;"); 
     data = data.Replace("<", "&lt;"); 
     data = data.Replace(">", "&gt;"); 

     return data; 
    } 

미리 감사드립니다.

+1

RSS 코드 또는 적어도 코드 조각보기 – Curt

+0

http://net.tutsplus.com/tutorials/asp-net/how-to-build-an-rss-feed-with-asp-net/ 코드 복사 위치 ... 나를위한 동일한 문제 –

답변

0

@Page 지시어의 ContentType을 "text/xml"로 설정하여 rss.aspx 페이지의 출력이 XML 문서임을 나타냅니다. 그것은 나를 위해 잘 작동합니다.

+0

나를 위해 작동하지 않습니다 –

+0

Google 크롬에 RSS 리더를 추가해야합니다. 그것은 당신을 위해 작동합니다. –

+0

인터넷 익스플로러에도 적합하지 않습니다. –

관련 문제