Note that there are some explanatory texts on larger screens.

plurals
  1. POSystem.Diagnostics.Process.Start() doesn't work in the web server
    primarykey
    data
    text
    <p>I have a C# asp.net web page which reads PDF file from Mysql database (which stores as longblob format) and open it. It works in my Localhost; the page reads the file from database and open with acrobat reader but it doesn't work in the testing server after i deploy the page. The acrobat reader doesn't open and i don't see acroRd32.exe in the taskmgr manager. I feel it is permission issue because i use process.start() which may not allow in the server but i dont see error messages. If there are permissions needs to be done in server; can anyone kindly points me the direction?</p> <p>Thank You.</p> <h2>Here are my code:</h2> <pre><code>MySqlDataReader Reader = null; connection.Open(); MySqlCommand command = new MySqlCommand("Select Image, File_Type, File_Name from table where ImageID = " + ImageID, connection); Reader = command.ExecuteReader(); if (Reader.Read()) { byte[] buffer = (byte[])Reader["Image"]; System.IO.MemoryStream stream1 = new System.IO.MemoryStream(buffer, true); stream1.Write(buffer, 0, buffer.Length); String fileName = Reader["File_Name"].ToString(); String dirName = "C:\\thefolder\\"; if (!Directory.Exists(dirName)) { // if not then create Directory.CreateDirectory(dirName); } if (File.Exists(dirName+fileName)) File.Delete(dirName + fileName); Directory.CreateDirectory(Path.GetDirectoryName(Reader["File_Name"].ToString())); using (Stream file = File.Create(dirName + fileName)) { file.Write(buffer, 0, buffer.Length); } Process process = new Process(); process.StartInfo.FileName = "AcroRd32.exe"; process.Start(); } </code></pre> <p>Thanks for your help, i am able to send pdf content via response. Here is the code</p> <pre><code>//Process process = new Process(); //process.StartInfo.FileName = "AcroRd32.exe"; //process.Start(); Response.ClearHeaders(); Response.ContentType = "application/pdf"; Response.Clear(); Response.AppendHeader("Content-Disposition", "attachment"); Response.TransmitFile(dirName + fileName); Response.End(); </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload