How do I open a pdf file that has been saved on the server on the client side. I was creating a process to do this but it has not worked
(System.Diagnostics.Process.Start(pdfFilePath + pdffileName);). 
I need to open this file on the client side as they need to send it the label print. 
            Asked
            
        
        
            Active
            
        
            Viewed 59 times
        
    -1
            
            
        
        Sheena Weber
        
- 53
 - 1
 - 7
 
- 
                    Post any error messages, also what do you mean by "has not worked" – Harry Mar 31 '15 at 14:48
 - 
                    there where no error messages as nothing was happening. I had been using the process.start to open the pdf file locally while I was still developing when I published my site I tried to load the pdf file from the site and now nothing is happening. I am not to sure what I could do to fix this. – Sheena Weber Mar 31 '15 at 14:57
 
3 Answers
0
            
            
        Have a look here: .NET MVC FileResult equivalent in Web Forms
The response marked as answer should also fit your needs.
        Community
        
- 1
 - 1
 
        LocEngineer
        
- 2,847
 - 1
 - 16
 - 28
 
0
            try to write the file into the response. You try to open it on the server.
Context.Response.Buffer = false;
        FileStream inStr = null;
        byte[] buffer = new byte[1024];
        long byteCount; inStr = File.OpenRead(pdfFilePath + pdffileName);
        while ((byteCount = inStr.Read(buffer, 0, buffer.Length)) > 0) {
            if (Context.Response.IsClientConnected) {
                Context.Response.ContentType = "application/pdf";
                Context.Response.OutputStream.Write(buffer, 0, buffer.Length);
                Context.Response.Flush();
            }
        }
        fubo
        
- 44,811
 - 17
 - 103
 - 137
 
0
            
            
        You either need to stream the file to the client (as the answer above indicates), or save it to a location under the site and give the user a link to it. You shouldn't need to start a process - link to the file and the browser will figure out what application to use to open it.
(You MAY need to set up a MIME type in IIS)
For example, assuming you save in the site under PDFFiles:
HyperLink pdfLink = new Hyperlink();
pdfLink.NavigateUrl = "~/PDFFiles/" + filename
Then add the link to your page controls. (Or you can hard-code the link in the ASPX file and set the NavigateUrl attribute in codebehind - however you want to do it)
        Tim
        
- 4,051
 - 10
 - 36
 - 60