How to make download link in asp.net?

I store images in database as byte array.And I want to open the image in a page after clicking
button.I have tried response.binarywrite() method keeping the page content type=”image” but can not save that in jpg or jpeg format.so how to do in c#?

You use below code:


string FileName ="image1.jpg";
byte[] bytes =  // get from the database table using your DB code/function
Response.Clear();
Response.AppendHeader("Content-Disposition", "filename=" + FileName);
Response.AppendHeader("Content-Length", bytes.Length.ToString());
Response.ContentType = "application/octet-stream";
Response.BinaryWrite(bytes);
Response.End();

About the Author

avatar