Return "application/xml" instead of "text/plain" ASP.NET Core Web API
<p>I have a string that is XML and I need to return it as an XML document. By default, this is returned with the content type of <code>text/plain</code>. The content is rendered, but I need the content type to be <code>application/xml</code>. I've enabled the option RespectBrowserAcceptHeader, which will serialize objects as XML and set the correct content type, except if the object is a string.</p>

<pre><code>[HttpGet]
public string Get()
{
   return xmlString;
}

public static string xmlString = @"&lt;?xml version=""1.0"" encoding=""UTF-8""?&gt;
                     &lt;sample&gt;
                         Hello World.
                     &lt;/sample&gt;";
</code></pre>