Reputation: 39
I've created an ActionResult
in an MVC
controller which returns a FileStreamResult
of an XMLfile
, but it's not downloading the file.
After the action returns the FileStream
nothing happens; I'd like to make the user download the file from the web application.
Any help? Thanks
public ActionResult EsportaProtocollo(int idProtocollo)
{
AvvisoModel avviso = new AvvisoModel();
string xml = _protocolliService.ProtocolloToXml(idProtocollo);
var newStream = new System.IO.MemoryStream();
var writer = new System.IO.StreamWriter(newStream);
writer.Write(xml);
writer.Flush();
newStream.Position = 0;
return File(newStream, "application/xml", "prova.xml");
}
Here's what I see on Fiddler
Upvotes: 0
Views: 1213
Reputation: 39
Solved! the problem was the javascript, i was calling the action with an ajax call, i've changed it to a window.open(url); and now it works!
Upvotes: 1