This is a general question about MVC as a pattern, but in this case I am using ASP.NET MVC.
I need to create an application whose output is an HTTP-accessed XML stream (content type text/xml).
I can do this using traditional ASP.NET using a Generic Handler object.
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "text/xml";
context.Response.Write(someXmlText);
}
Can I create an ASP.NET MVC View that achieves the same result?
Is this an appropriate use of an MVC View?
You can use MvcContrib’s XmlResult. This works just like your example above. You don’t need to use a view to render the XML.
In essence – you have an action on a controller that returns the XML.