return a file, c#, asp.net

string filename = "myfile.typ";
string fileStr = "";
System.Text.UTF8Encoding encoding = new System.Text.UTF8Encoding();
byte[] bytes = encoding.GetBytes(fileStr);
//or any other way to serialize your file

Response.Clear();
Response.ContentType = "application/ics;charset=utf-8";

//the general rule is (1) google (2) application/fileType (3) if is text then text/fileType
Response.AddHeader("content-disposition", "inline;filename=" + filename);
Response.BinaryWrite(bytes);
Response.End();
Response.Flush();

Comments

Popular posts from this blog

OverTheWire[.com] Natas Walkthrough - JUST HINT, NO SPOILERS

Asp.Net Ending Response options, Response.End() vs CompleteRequest()

SOLVED The item could not be indexed successfully because the item failed in the indexing subsystem