Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I output xml with ASP.NET razor?

Hi I'm trying to return a view that is xml, meaning the content type will be "text/xml", and the view is using ASP.NET MVC razor. Another post ASP.NET MVC and text/xml content type showed how to do it with aspx view. How do I get the same done with razor?

like image 884
Ray Avatar asked May 09 '11 22:05

Ray


1 Answers

If you prefer you can instead make the content type change from your view action, like so:

public ActionResult MyAction() {
    Response.ContentType = "text/xml";
    return View();
}
like image 101
Luis Perez Avatar answered Oct 19 '22 02:10

Luis Perez