If you return FileResult it will be file, if you return string it will be open in browser.
Update: This code will return file for downloading
public FileResult GetXmlFile()
{
string xml=""; //string presented xml
var stream = new MemoryStream();
var writer = XmlWriter.Create(stream);
writer.WriteRaw(xml);
stream.Position = 0;
var fileStreamResult = File(stream, "application/octet-stream", "xml.xml");
return fileStreamResult;
}
No comments:
Post a Comment