ich eine Anfrage über Ajax senden und wenn Antwortdaten Erfolg ist wahr, ich mache eine GET-Anfrage in Ajax-Erfolg Funktion:Datei herunterladen über GET und gibt die Referrer-URL
success: function (data, status) {
if (!data["Success"]) {
alert("Error occurred: Cant read data properly," + data["Message"]);
return null;
}
window.location = '/Home/downloadanddelete?file=output.' + data["filetype"];
Das Problem ist, wenn Get-Anfrage gebucht die Antwort auf der Steuerung ist:
Wie Sie die Datei uRL sehen ist: „http://localhost:53091/Home/downloadanddelete?file=output.xml“
und ich erwarte, dass diese ‚output.xml‘ Datei herunterladen und die Referrer-uRL zurück.
hier ist Download-Methode in der Steuerung:
[HttpGet]
public ActionResult downloadanddelete(string file)
{
string fullName = Path.Combine(HttpRuntime.AppDomainAppPath, "App_Data", file);
if (System.IO.File.Exists(fullName))
{
return File(fullName, "application/xml");
}
return View("Index");
}
Was ist das hier falsch?
Es sieht aus wie es ist "Herunterladen"; Wollen Sie, dass das XML als Datei heruntergeladen werden soll? – Jacob
Ja Ich möchte die Datei output.xml heruntergeladen sehen .. nicht den Inhalt im Browser .. – TyForHelpDude