B
Brett Kelly
Ok, I know this sounds odd. Let me explain further.
I have an ASP.net page (w/ C# code behind) that, when given a session
variable containing the path to a local file, will attempt to start the
download of that file for the user.
Here's the content of my Page_Load:
protected void Page_Load(object sender, EventArgs e)
{
if (Response.IsClientConnected)
{
string fname = Session["fn"].ToString();
Response.ContentType = "application/octet-stream";
Response.AddHeader("Content-Disposition",
"attachment;filename=" +
fname);
Response.WriteFile(fname);
}
}
Somehow, this code will append the html/css code from the download page
to the end of the file being downloaded. For Example, say i'm trying
to download test.txt that contains one line:
----------------------------
This is a test
----------------------------
When i download the file, I get this:
----------------------------
This is a test
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head><title>
Untitled Page
</title></head>
<body>
<form name="form1" method="post" action="sf.aspx" id="form1">
<div>
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE"
value="/wEPDwUJNzgzNDMwNTMzZGT/M1xVFtSmiLzmcScAG5lBHRlqGw==" />
</div>
<div></div>
</form>
</body>
</html>
-------------------------
Now, I've tried clearing the Response buffer before sending the file,
but no dice.
Any suggestions?
I have an ASP.net page (w/ C# code behind) that, when given a session
variable containing the path to a local file, will attempt to start the
download of that file for the user.
Here's the content of my Page_Load:
protected void Page_Load(object sender, EventArgs e)
{
if (Response.IsClientConnected)
{
string fname = Session["fn"].ToString();
Response.ContentType = "application/octet-stream";
Response.AddHeader("Content-Disposition",
"attachment;filename=" +
fname);
Response.WriteFile(fname);
}
}
Somehow, this code will append the html/css code from the download page
to the end of the file being downloaded. For Example, say i'm trying
to download test.txt that contains one line:
----------------------------
This is a test
----------------------------
When i download the file, I get this:
----------------------------
This is a test
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head><title>
Untitled Page
</title></head>
<body>
<form name="form1" method="post" action="sf.aspx" id="form1">
<div>
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE"
value="/wEPDwUJNzgzNDMwNTMzZGT/M1xVFtSmiLzmcScAG5lBHRlqGw==" />
</div>
<div></div>
</form>
</body>
</html>
-------------------------
Now, I've tried clearing the Response buffer before sending the file,
but no dice.
Any suggestions?