Skip to content

Instantly share code, notes, and snippets.

@eit
Last active December 21, 2015 18:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eit/6349268 to your computer and use it in GitHub Desktop.
Save eit/6349268 to your computer and use it in GitHub Desktop.
//指定ContentType
context.Response.ContentType = _contentType;
//檔案Response出去 註:這邊會將檔案整個Response出去但是並不會顯示路徑!!
context.Response.WriteFile(ConfigurationManager.AppSettings["files_folder_PhysicalPath"] + _file);
string _fileName = HttpUtility.UrlPathEncode( Path.GetFileName(_file));
string strContentDisposition = String.Format("{0}; filename=\"{1}\"", "inline", _fileName);
context.Response.AddHeader("Content-Disposition", strContentDisposition);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment