How would you generate RSS using ASP.Net MVC? I have the data in the database already and I'll transform it as necessary. My first approach is to create an RSS template that I use as a view, but that seems error prone and since RSS is a structured format there could be a class that I set some properties and generates RSS. Is there such a thing? How would you do it?
            Asked
            
        
        
            Active
            
        
            Viewed 1,571 times
        
    6
            
            
        - 
                    5possible duplicate of http://stackoverflow.com/questions/11915/rss-feeds-in-asp-net-mvc – CoderDennis Jun 22 '09 at 23:10
3 Answers
7
            Here's an interesting article - http://www.developerzen.com/2009/01/11/aspnet-mvc-rss-feed-action-result/
It creates an RssActionResult class that sets the content type, and Syndication items to render the View.
 
    
    
        Pablo Fernandez
        
- 279,434
- 135
- 377
- 622
 
    
    
        David
        
- 15,150
- 15
- 61
- 83
4
            
            
        Use WCF System.ServiceModel.Syndication namespace for which you need to add System.ServiceMode.Web to your references. That handles the whole thing automatically:
using System.ServiceModel.Syndication;
// ...
var rss = new SyndicationFeed(...);
...
var formatter = new Rss20FeedFormatter(rss);
formatter.WriteTo(xmlWriter);
 
    
    
        Pablo Fernandez
        
- 279,434
- 135
- 377
- 622
 
    
    
        Mehrdad Afshari
        
- 414,610
- 91
- 852
- 789
1
            
            
        Here are a couple links:
http://www.developerzen.com/2009/01/11/aspnet-mvc-rss-feed-action-result/
 
    
    
        Community
        
- 1
- 1
 
    
    
        CoderDennis
        
- 13,642
- 9
- 69
- 105