I've been asked to wrap an RSS request into an ASP.NET WebAPI controller. What's the best way to do this?
Asked
Active
Viewed 368 times
-1
-
http://stackoverflow.com/questions/12437731/create-rss-feed-in-mvc4-webapi – Kiran Jul 01 '14 at 18:25
-
I'm not looking to create an RSS feed, I just need to pass through the XML file for an RSS feed. – Metaphor Jul 01 '14 at 18:29
-
i am still not clear...do you mean you would be passing the RSS feed xml to an Api controller action and would want that to be deserialized in some format? – Kiran Jul 01 '14 at 19:00
-
Reasons are convoluted but I have no say in the matter. I need to get the XML returned from an RSS call and return it intact. I imagine this can be done in the controller action as it does not require any models. – Metaphor Jul 01 '14 at 22:20
-
1Is there a a name for people who drive-by downvote without leaving a comment as to what it is they didn't like? I mean, I know what I call them privately, but there has to be a more politically correct name for the public. – Metaphor Jul 02 '14 at 18:46
1 Answers
1
Based on your last comment, you could do something like below:
public HttpResponseMessage Get()
{
HttpResponseMessage response = new HttpResponseMessage();
response.Content = new StreamContent(<Stream having xml content>);
// or
//response.Content = new StringContent("string having xml content");
response.Content.Headers.ContentType = new MediaTypeHeaderValue("application/rss+xml");
return response;
}

Kiran
- 56,921
- 15
- 176
- 161