close

不需要在站台產出暫存檔 可以下載文字檔

 

StringBuilder sb = new StringBuilder();
        string output = "Output";
        sb.Append(output);
        sb.Append("\r\n");
 
        string text = sb.ToString();
 
        Response.Clear();
        Response.ClearHeaders();
 
        Response.AppendHeader("Content-Length", text.Length.ToString());
        Response.ContentType = "text/plain";
        Response.AppendHeader("Content-Disposition", "attachment;filename=\"output.txt\"");
 
        Response.Write(text);
        Response.End();

 

來源 https://stackoverflow.com/questions/14755339/download-text-as-file-in-asp-net

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 davidctwood 的頭像
    davidctwood

    davidctwood的部落格

    davidctwood 發表在 痞客邦 留言(0) 人氣()