I'd like to return some XML instead of HTML in my WebMatrix cshtml file? How do you change the content type header?
Use the Response.ContentType property at the top of your .cshtml file then include the XML in the content of the view:
@{
Response.ContentType = "application/xml";
}
<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Dial>415-123-4567</Dial>
</Response>
At the top of your Razor file, set the ContentType of the Response object:
@{
Response.ContentType = "application/xml";
}
... xml here ...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With