Reputation: 220
i want to download a xml file,but i have a xml content in a string.
public FileResult Download(string id)//guid
{
string fid = Convert.ToString(id);
var model = service.GetAllDefinitions().First(x => x.ID == id);
var definitionDetails = new StatisticDefinitionModel(model);
var definition = definitionDetails.ToXml;
//in this definition i have xml content not a path
string fileName = definitionDetails.Name + ".xml";
string contentType = "text/xml";
return File(definition , contentType);
}
but this is not working,got error like illegal path.
Thanks,
Upvotes: 0
Views: 442
Reputation: 9497
EDIT Only the first option will work. Also, specify a default file name for client:
return File(Encoding.UTF8.GetBytes(definition), contentType, "somefilename.xml");
Upvotes: 1