Answered by:
RSS Feed

Question
-
User1608082067 posted
Hello,
On my ASP.NET MVC RC2 application I have two tables: Articles and Documents.
I need to create two RSS feeds: one for Articles and one for Documents.
How can I deliver this two lists as RSS in ASP.NET MVC?
Thanks,
Miguel
Thursday, March 12, 2009 10:30 PM
Answers
-
User-1384221439 posted
This topic was discused here: http://stackoverflow.com/questions/11915/rss-feeds-in-asp-net-mvc
I like this solution: http://www.developerzen.com/2009/01/11/aspnet-mvc-rss-feed-action-result/- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Friday, March 13, 2009 4:48 AM -
User-1910946339 posted
Delete lines 2 to 5. The blog article is just showing you what the Mvc definition of ActionResult is like. It is not intended that you re-implement it. The RssActionResult class inherits from System.Web.Mvc.ActionResult not from some class that you write.
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Friday, March 13, 2009 11:26 PM -
User-1384221439 posted
Agree.
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Saturday, March 14, 2009 3:52 PM
All replies
-
User-1384221439 posted
This topic was discused here: http://stackoverflow.com/questions/11915/rss-feeds-in-asp-net-mvc
I like this solution: http://www.developerzen.com/2009/01/11/aspnet-mvc-rss-feed-action-result/- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Friday, March 13, 2009 4:48 AM -
User1608082067 posted
Hi,
I am following the developerzen example but I get an error on my controllers action:
return new RssActionResult() { Feed = feed };
Cannot create an instance of the abstract class or interface 'MyApp.Mvc.RssActionResult'
Any idea what is wrong?
I followed all steps and everything seems ok.
Thanks,
Miguel
Friday, March 13, 2009 2:11 PM -
User-1384221439 posted
I check code at http://www.developerzen.com/2009/01/11/aspnet-mvc-rss-feed-action-result/ and all seems OK - this must work! :) Could you provide your code please?
Friday, March 13, 2009 4:37 PM -
User1608082067 posted
Hi Augi
Sorry for the delay ... I have been trying to solve the problems that I get with this code.
I am using the following:
1 namespace MyApp.Mvc { 2 public abstract class ActionResult { 3 protected ActionResult(); 4 public abstract void ExecuteResult(ControllerContext context); 5 } 6 7 public class RssActionResult : ActionResult { 8 public SyndicationFeed Feed { get; set; } 9 public SyndicationFormat Format { get; set; } 10 public override void ExecuteResult(ControllerContext context) { 11 context.HttpContext.Response.ContentType = "application/rss+xml"; 12 using (XmlWriter writer = XmlWriter.Create(context.HttpContext.Response.Output)) { 13 switch (Format) { 14 case SyndicationFormat.Atom: 15 Rss20FeedFormatter atom = new Rss20FeedFormatter(this.Feed); 16 atom.WriteTo(writer); 17 break; 18 case SyndicationFormat.Rss: 19 Rss20FeedFormatter rss = new Rss20FeedFormatter(this.Feed); 20 rss.WriteTo(writer); 21 break; 22 } 23 } 24 } // ExecuteResult 25 26 [AcceptVerbs(HttpVerbs.Get)] 27 public ActionResult Subscribe(Guid id) { 28 YSyndication syndication = SyndicationService.GetSyndication(this, id); 29 SyndicationFeed feed = SyndicationService.GetFeed(this, syndication, 20); 30 return new RssActionResult() { Feed = feed, Format = syndication.Format }; 31 } 32 } 33
Now I get the error on all controllers ActionResults:
'ActionResult' is an ambiguous reference between 'MyApp.Mvc.ActionResult' and 'System.Web.Mvc.ActionResult'
I understand why ... but I would like to avoid this conflict so I changed my ActionResult to:
public abstract class ActionResult : System.Web.Mvc.ActionResult { ' ... }
The same problem happens. Then I tried:
public abstract class ActionResultCore : System.Web.Mvc.ActionResult { protected ActionResultCore(); public abstract void ExecuteResult(ControllerContext context); } // ActionResult
And I got the errors:
- 'MyApp.Mvc.ActionResultCore.ActionResultCore()' must declare a body because it is not marked abstract, extern, or partial
- 'MyApp.Mvc.ActionResultCore.ExecuteResult(System.Web.Mvc.ControllerContext)' hides inherited abstract member 'System.Web.Mvc.ActionResult.ExecuteResult(System.Web.Mvc.ControllerContext)'
Anyway, I don't understand very well the part:
protected ActionResultCore();
And I am a little bit lost of how to make this work.
Could you please, help me out?
Thanks,
Miguel
Friday, March 13, 2009 8:19 PM -
User-1910946339 posted
Delete lines 2 to 5. The blog article is just showing you what the Mvc definition of ActionResult is like. It is not intended that you re-implement it. The RssActionResult class inherits from System.Web.Mvc.ActionResult not from some class that you write.
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Friday, March 13, 2009 11:26 PM -
User-1384221439 posted
Agree.
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Saturday, March 14, 2009 3:52 PM -
User1608082067 posted
Thank You All. It is working now!
Sunday, March 15, 2009 1:22 PM