Deuxième téléchargement impossible
Bonjour ,
Je suis sur un projet ASP.Net . J'ai besoin de lancer un téléchargement d'un fichier word (.docx) . Tout fonctionne correctement au premier téléchargement , mais impossible d'en effectuer des supplémentaire sans rafraichir la page.
Cela me renvoie une exception de type 'System.NullReferenceException' , classique :) .
Voici mon ActionResult en question :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
| public ActionResult Download()
{
ReportByClientViewModel data = (ReportByClientViewModel)TempData["ReportByClient"];
string filename = "export.docx";
Response.AppendHeader("Content-Disposition", "attachment; filename=" + filename);
MemoryStream s = new MemoryStream();
ExportReport.ExportToWord(s, data.Report); //Bug at the second download
s.Position = 0;
s.CopyTo(Response.OutputStream);
return File(s, "application/x-doc", filename);
} |
Je me doute que le problème vient du MemoryStream , mais si quelqu'un peut m'expliquer c'est pas de refus.
Merci