Ich muss eine CSV-Datei als HTTP-Antwort senden. Wie kann ich die Ausgabeantwort als CSV-Format festlegen?
Das funktioniert nicht:
Response.ContentType = "application/CSV";
Ich muss eine CSV-Datei als HTTP-Antwort senden. Wie kann ich die Ausgabeantwort als CSV-Format festlegen?
Das funktioniert nicht:
Response.ContentType = "application/CSV";
Für C# MVC 4.5 müssen Sie wie folgt vorgehen:
Response.Clear();
Response.ContentType = "application/CSV";
Response.AddHeader("content-disposition", "attachment; filename=\"" + fileName + ".csv\"");
Response.Write(dataNeedToPrint);
Response.End();
return new EmptyResult(); //this line is important else it will not work.
CodeJaeger ist eine Gemeinschaft für Programmierer, die täglich Hilfe erhalten..
Wir haben viele Inhalte, und Sie können auch Ihre eigenen Fragen stellen oder die Fragen anderer Leute lösen.