2011-10-21 5 views
1

MVC 3, VBNET 및 EF를 사용하여 RSS 피드를 생성 중입니다. 그러나 내가 IE에서 피드 url을 볼 때, 제대로 렌더링되지 않습니다 - 내가보기에 텍스트 문자열과 HTML 태그가 인코딩되었습니다. 또한 코드 RSS 피드가 제대로 렌더링되지 않습니다 - MVC 3 사용

http://riderdesign.net/img/s8/v9/p206604261-4.jpg

같은 렌더링 된 출력이 모습에 대한 이미지 :

Public Function RSS() As ActionResult 

     Dim blogTitle = "RiderDesign Blog" 
     Dim blogDescription = "The latest posts from RiderDesign" 
     Dim blogUrl = "http://riderdesign.com" 
     Dim postUrl = "http://riderdesign.com/Blog/Post/" 

     Dim blogItems = _postService.SelectPublishedPosts.ToList() 
     Dim postItems = New List(Of SyndicationItem)() 
     For Each item In blogItems 
      Dim post = New SyndicationItem() 
      post.Title = New TextSyndicationContent(item.PostTitle) 
      post.Summary = SyndicationContent.CreateHtmlContent(item.PostExcerpt) 
      post.LastUpdatedTime = CType(item.PostDateCreated, DateTime) 
      post.Content = SyndicationContent.CreateHtmlContent(item.PostText) 
      post.AddPermalink(New Uri(postUrl + item.PostId.ToString)) 
      postItems.Add(post) 
     Next 

     Dim feed = New SyndicationFeed(blogTitle, blogDescription, New Uri(blogUrl), postItems) With { _ 
     .Copyright = New TextSyndicationContent("Copyright " & DateTime.Now.Year.ToString() & " RiderDesign.com"), _ 
     .Language = "en-US" _ 
     } 

     Return New FeedResult(New Rss20FeedFormatter(feed)) 
     'Return New FeedResult(New Atom10FeedFormatter(feed)) 
    End Function 

    Public Class FeedResult 
    Inherits ActionResult 
    Public Property ContentEncoding() As Encoding 

    Public Property ContentType() As String 

    Private ReadOnly m_feed As SyndicationFeedFormatter 
    Public ReadOnly Property Feed() As SyndicationFeedFormatter 
     Get 
      Return m_feed 
     End Get 
    End Property 

    Public Sub New(ByVal feed As SyndicationFeedFormatter) 
     Me.m_feed = feed 
    End Sub 

    Public Overrides Sub ExecuteResult(ByVal context As ControllerContext) 
     If context Is Nothing Then 
      Throw New ArgumentNullException("context") 
     End If 

     Dim response As HttpResponseBase = context.HttpContext.Response 
     response.ContentType = If(Not String.IsNullOrEmpty(ContentType), ContentType, "application/rss+xml") 

     If ContentEncoding IsNot Nothing Then 
      response.ContentEncoding = ContentEncoding 
     End If 

     If m_feed IsNot Nothing Then 
      Using xmlWriter = New XmlTextWriter(response.Output) 
       xmlWriter.Formatting = Formatting.Indented 
       m_feed.WriteTo(xmlWriter) 
      End Using 
     End If 
    End Sub 
End Class 

답변

0

피드는 코드를 변경하지 않고 올바르게 표시됩니다. 이유는 모르겠다. '

관련 문제