In my ASP.net c# MVC project, I want to get raw XML generated from reading DB.
I am getting XML response back, but problem is that my complete XML shows as plain string within my string
What should I change to make this response a well formated XML output?
Below is what I have got
public override void ExecuteResult(ControllerContext context)
{
if (this.objectToSerialize != null)
{
context.HttpContext.Response.Clear();
var xs = new System.Xml.Serialization.XmlSerializer(this.objectToSerialize.GetType());
context.HttpContext.Response.ContentType = "text/xml";
context.HttpContext.Response.ContentEncoding = UTF8;
xs.Serialize(context.HttpContext.Response.Output, this.objectToSerialize);
}
}