Basically I return the list of files and the id to a datagrid. When I click on the link to "open" the file, IE 7 opens a new window and then immediately closes the window. The process works fine if it's running on localhost, but when I move it to the webserver is where the problem happens. In straight html I would set the link target to "download" and everything would work fine. I'm not sure if there is an equivilent way of doing this with c#. Below is the code for downloading the file.
Expand|Select|Wrap|Line Numbers
- fitguru.dfDataAccess data = new fitguru.dfDataAccess();
- int docnumber = 0;
- try
- {
- docnumber = int.Parse(Request.QueryString["dfPk"]);
- }
- catch(System.ArgumentNullException ee)
- {
- docnumber = 0;
- }
- int dfDocPk = (Convert.ToInt32(Request.QueryString["dfPk"]));
- byte [] buffer = data.getDoc(dfDocPk);
- System.IO.MemoryStream stream1 = new System.IO.MemoryStream(buffer,true);
- stream1.Write(buffer,0,buffer.Length);
- if(docContent == "doc")
- {
- Response.ContentType = "application/msword";
- }
- else if(docContent == "xls")
- {
- Response.ContentType = "application/vnd.ms-excel";
- }
- Response.OutputStream.Write(buffer,0,buffer.Length);
- Response.End();