New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RSS and Atom ASP.NET Core ActionResult classes #2218
Comments
@drago-draganov thoughts? |
@RehanSaeed Here is my take on it: The difference between forward-only writer and document oriented is that the first one doesn't have understanding of state and intrinsic data. That allows it to be very lightweight at almost every aspect. MVC ActionResult primary focus is on passing along already established data (content, status, type, etc.). An MVC Controller action is the proper place for business logic to establish that data (model). FileResult perhaps is a close analogy of the topic here. Note that once returned it already knows all the information needed (file path) to proceed. It augments only the details of how to put the entire file content on the wire. Microsoft.SyndicationFeedWriter in contrast still requires all the feed data: title, description, links, items, etc. to be placed - this is where most of the code goes anyway. Here is pretty much what raw code (without special RssActionResult) could look like when using SyndicationFeedWriter in ASP.NET MVC. It seems simple already.
|
Agreed, the stream model does not work well with |
@RehanSaeed You could always create your own SyndicationFeed model. Your MVC action would then pass the model to your RssResult. The RssResult class would then write the model to the Response.
|
@ToddThomson indeed I did make a simple SyndicationFeed model and you are very helpful, showing me how to use it above. However, what would one do when content negotiation comes into the picture? What would one do when we want to produce Atom or RSS output from a single endpoint? |
It is fairly common to want to return an RSS or Atom feed from an ASP.NET Core application. It would be nice to include an
ActionResult
class that wraps theRss20FeedWriter
orAtomFeedWriter
. These classes could be included in another assembly so it's opt-in.Unfortunately, the
Rss20FeedWriter
class as it is now is not easily wrappable, this is the best I could do below. Perhaps the answer is that the new feed writer is simple enough it does not need anActionResult
. I used to to this with the oldSyndicationFeed
object.The text was updated successfully, but these errors were encountered: