i am trying to open the downloaded file from database in a new browser window..
here is code that i tried..
result = objBL.GetLetter(LetterID, refNo, attachmentType);
if (result != null && result.Rows.Count > 0)
{
DataRow dr = result.Rows[0];
string fileName = dr["FileName"].ToString();
Response.ContentType = ContentType;
Response.AppendHeader("Content-Disposition", "attachment; filename=" + Path.GetFileName(fileName));
Response.WriteFile(Server.MapPath("~/Attachments/" + fileName));
Response.End();
}
is there any syntax to open in jquery?
The code you provided isn't jQuery, it's C#. This question actually has nothing to do with jQuery, so please be mindful not to add irrelevant tags to your question next time :).
To open a (downloaded) file in the browser, set the Content-Disposition
header for your Response
object to inline
. Currently, you are setting it to attachment
which forces it to be downloaded as a file instead of being displayed in the browser.
Example:
Response.AppendHeader("Content-Disposition", "inline; filename=" + Path.GetFileName(fileName));
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.