Please see my other MVC articles.
Returning different types of content.
MVC provide flexibility when answering requests for resources by supporting different types of content.
In this article, I will illustrate the use of the ContentType to return plain text and XML.
Here I have a simple example of how a Controller may return plain text to the browser.
Notice the second parameter I give the Content() method – “text/plain.”
When calling the Controller, you’ll notice that plain text is returned – content with no HTML tags.
In the next example, I’ve created a Controller that returns an example XML document for sales associates.