Writing XML in Razor

Posted by:

On one of our recent projects, we needed to add a feature to a client’s website that would dynamically generate XML in a Razor CSHTML file.

In order to do this, we first needed to tell razor that we’re writing XML, which we did by quite simply writing code to set Response.ContentType to XML’s MIME type (text/xml). We also had to set the layout property to be null, to ensure that no HTML from the master pages is added to the ...

Continue Reading →