I want to open pdf in browser without downloading it but in my code whenever I click on a pdf file to open it ....
it ask to download it here is my code.
protected void Page_Load(object sender, EventArgs e)
{
if (!string.IsNullOrEmpty(Request.QueryString["FileName"]))
{
string fileName = Request.QueryString["FileName"];
string filePath = Server.MapPath("~/files/") + fileName;
string fileExtension = Path.GetExtension(filePath);
// byte[] bytes=null;
switch (fileExtension.ToLower())
{
case ".txt":
Response.Write(File.ReadAllText(filePath));
break;
case ".pdf":
Response.ContentType = "Application/pdf";
Response.ContentType = "\".pdf\", \"application/pdf\"";
Response.AppendHeader("Content-Disposition", "attachment; filename=" + fileName);
Response.WriteFile(filePath);
Response.End();