ASP.NET downloads a file directly instead of opening it in IE

xiaoxiao2021-03-06  80

Sometimes we don't want users to open known types of files directly in IE, such as Word, and hope to download directly, at this time, you can use the following code to replace Response.Redirect

Response.ContentType = "application / octet-stream"; Response.AddHeader ( "Content-Disposition", "attachment; FileName =" YourFileName); Response.BinaryWrite ((byte []) YourFileData.Rows [0] [ "AttachmentContent "]); Response.end ();

转载请注明原文地址:https://www.9cbs.com/read-120908.html

New Post(0)