I am storing some files like PDF, Doc, Docx, xls etc. in the file system.
Now I have to show those files on the browser for the users to view.
So basically a link button is there in a datagrid, upon clicking on which the user will be able to view.
So far my code goes like this
Response.Clear();
// Response.ContentType = "application/pdf";
//Response.ContentType = "application/x-msexcel";
//Response.ContentType = "application/msword";
string strFilePath = @"C:\test.pdf";
// string strFilePath = @"C:\test.doc";
Response.WriteFile(strFilePath);
Response.End();
This works fine for pdf files but fails for word or excel files. In the browser I am able to view the pdf but the other files are not opening in browser but are asking for the
Save
, Open
dialog box option. If I click on Open
, it will open in a normal window instead of browser.
How can I achieve my target? The browser is IE
Thanks in advance
Best Answer
have you tried adding something like this?