I have a c# web app on .net 1.1 framework. Currently I have a process where I can upload files (.doc, .xls, etc) to a my sql database. When trying to open the files however I'm running into an issue with IE7.
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.
any ideas how to resolve this? thanks
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.
Code:
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();