title: .Net Core XmlDocument doesn't return declaration
body: <p>I have a .net core web application with a XmlDocument, this doesn't return declaration, even without modifications.</p>
  
  <p>I have this code</p>
  
  <pre><code>[HttpPost]
  [Consumes("application/xml")]
  [Produces("application/xml")]
  public ActionResult&lt;XmlDocument&gt; GW1()
  {
      XmlDocument xmlDocRec = new XmlDocument();
      xmlDocRec.Load(Request.Body);
      return Ok(xmlDocRec);
  }
  </code></pre>
  
  <p>Request</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;GR User="User1" PropertyCode="90001045"&gt;
      &lt;GW&gt;1&lt;/GW&gt;
  &lt;/GR&gt;
  </code></pre>
  
  <p>Response</p>
  
  <pre><code>&lt;GR User="User1" PropertyCode="90001045"&gt;
      &lt;GW&gt;1&lt;/GW&gt;
  &lt;/GR&gt;
  </code></pre>
  
  <p>I have this in Startup</p>
  
  <pre><code>services.AddMvc()
                  .SetCompatibilityVersion(CompatibilityVersion.Version_2_1)
                  .AddXmlSerializerFormatters();
  </code></pre>
  
  <p>I need in response <code>&lt;?xml version="1.0" encoding="utf-8"?&gt;</code> but i don't know why it doesn't not return. In xmlDocRec.InnerXml and xmlDocRec.OuterXml exists.</p>
  
  <p>I haven't class as parameters and response neither, i can't use it for requirement, for that i use Request.Body</p>
  
  <p>Obviously i work with xmlDocRec, i add and update elements, but result is the same. When i work with xmlDocRec, xmlDocRec.InnerXml and xmlDocRec.OuterXml contains <code>&lt;?xml version="1.0" encoding="utf-8" standalone="no"?&gt;</code>. Later, i will need to delete standalone="no" because it must not be in response.</p>
  
  <p>--- Edit</p>
  
  <p>I don't know if it is rigth way, but for now i'm using this</p>
  
  <pre><code>[HttpPost]
  public ContentResult GW1()
  {
      XmlDocument xmlDocRec = new XmlDocument();
      xmlDocRec.Load(Request.Body);
  
      return new ContentResult
      {
          ContentType = "application/xml",
          Content = xmlDocRec.OuterXml,
          StatusCode = 200
      };
  }
  </code></pre>
  
  <p>With that, i don't need Consumes, Produces and AddXmlSerializerFormatters in startup.</p>
  
  <p>If some know a better way I'm willing to try.</p>