views:

159

answers:

1

I'd like to return some XML instead of HTML in my WebMatrix cshtml file? How do you change the content type header?

+11  A: 

Use the Response.AddHeader method at the top of your .cshtml file then include the XML in the content of the view:

@{ 
   Response.AddHeader("Content-Type", "application/xml"); 
}
<?xml version="1.0" encoding="UTF-8"?>
<Response>
    <Dial>415-123-4567</Dial>
</Response>
John Sheehan