Ich habeWie MVC Datei in AsyncControl herunterladen?
public class FileController : AsyncController
{
public ActionResult Download(FormCollection form)
{
FileContentResult file = new FileContentResult(Encoding.UTF8.GetBytes("10k file size"),"application/vnd.xls");
file.FileDownloadName = "test.xls";
return file;
}
}
und natürlich, ajax Form
<% var form = Ajax.BeginForm(...) %>
<input type="image" src="...gif" /> // this is my 1st attempt
<%= Ajax.ActionLink(...) %> // 2nd attempt
<% form.EndForm(); %>
- i versuchen erste Methode (input type = Bild). es erreicht die richtige Aktion. aber kein Dateidownload auf der Client-Seite.
- Dann versuche ich Ajax.ActionLink, die ich wirklich hasse. Ich möchte einen schönen Bild-Button, keinen Link-Text. Erneut erreicht er korrekte Aktion und keinen Dateidownload. Aber wenn ich Link in einem anderen Fenster öffne, gibt es Dateidownload !!
Q. Wie mit AsyncController
Q. Wie man Ajax.ActionLink lok schön
zuerst dachte ich, AsyncController = AjacController. aber es ist nicht. – Bonshington