I have an ASP.NET WebAPI method that returns a string containing a valid XML document:
public class MessageController : ApiController
{
private readonly MyContextProvider _contextProvider = new MyContextProvider();
[HttpGet]
public string Message()
{
Message m = _contextProvider.Context.Messages.First();
return m.XMLFile;
}
}
I call this method from the client using jQuery:
$.ajax('http://localhost:16361/service/api/message/message/', {
contentType: 'text/xml',
type: 'GET'
}).done(function (e) { });
'e' contains the string of XML but this is not what I want. I would like to let the browser handling the response and showing its usual dialog box to save or open the XML. Obviously I'm missing something here but I'm not sure how to do it...