I want open pdf file directly without asking open,save options(prompt window).In this temppath is path to the pdf in my website.But using this code new window is opening but file not opening.When I copy the tempath directly to the brower its opening.
Code:
string url = tempPath;
ScriptManager.RegisterClientScriptBlock(this, this.GetType(), Guid.NewGuid().ToString(), "window.open ('" + url + "');", true);
As reported in the comments, tempPath’s value is
F:\Project Files\OO\Source\VCRT\StockListDocument\57-StockListPDF27December11111505179.pdfThe browser can’t access local files unless you are on the same network. If you are, then the url needs to be prefixed with file:\ instead of http:\. If this is going to be served to end users, then you need to map the file path to a directory relative to the web server (i.e. the file needs to be in a subdirectory).
If the file is in a subdirectory and you have the full path to the file, you can user Server.MapPath to generate the appropriate file location.
If the file is not relative to the web server, you will either have to copy it from its current location to a subdirectory of the website or you will have to create an HTTPHandler to serve up the file from its current location.