Return XML file from Web API
Dependency Inversion Priciple

The smell is that your code violates the Dependency Inversion Priciple which reads


  Entities must depend on abstractions not on concretions. It states that the high level module must not depend on the low level module, but they should depend on abstractions.


This meas that your API depends on the Load method of the XmlDocument and not an abstraction such as a service like this one.

interface IXmlLoader
{
    XmlDocument Load(string path);
}


In consequence you cannot replace it for testing or use dependency injection and easily exchange it later if necessary. A correct implementation could look like this where you pass the dependency via the constructor. In some cases it might be also a property:

class XmlController
{
    private readonly IXmlLoader _xmlLoader;
    public XmlControler(IXmlLoader xmlLoader)
    {
        _xmlLoader = xmlLoader;
    }

    // Sometimes a property.
    // public IXmlLoader XmlLoader { get; set; }

    [HttpGet]
    public async Task&lt;IActionResult&gt; Get()
    {
        await Task.Run(() =&gt; _xmlLoader.Load(_appEnvironment.WebRootPath + @"\\user.config"));
        return Ok(xmlDoc);
    }    

}


This is just an example. In your real code you should add null checks.



Another smaller smell is the hardcoded string user.config that you should at least configure via a property.