S
Scott C. Reynolds
I want to serve a PDF right to a web page (cannot link browser directly
to PDF file). Stumbled across Response.WriteFile this morning. On my
machine (XP Pro) this worked fine:
private void Page_Load(object sender, System.EventArgs e)
{
string filePath = "c:\\somepath\\some.pdf";
Response.ContentType = "Application/pdf";
Response.WriteFile(filePath);
}
Hit the page in Firefox, PDF loads right up. Hit it in IE, nothing.
Just a broken puzzle icon.
Further, one of the developers on my team did the exact same thing and
it doesn't work at all. IE prompts him to save or open, which will save
the PDF (but it opens as a .aspx so he gets PDF gibberish in VS.NET if
he chooses open), and in Firefox he gets a message about the file being
corrupt.
The eventual goal is to do the same with a file on another computer (not
on the web server), so the questions are:
1)Why isn't it working properly in IE?
2)Why would it work on one machine and not another?
3)Any other tips regarding this?
Thank you very much in advance.
Scott.
--
____________________________________________
Scott C. Reynolds - Tales From the SharpSide
http://www.scottcreynolds.com
(e-mail address removed)
*****Get your SharpSide Swag!******
http://www.cafepress.com/sharpside/
***********************************
to PDF file). Stumbled across Response.WriteFile this morning. On my
machine (XP Pro) this worked fine:
private void Page_Load(object sender, System.EventArgs e)
{
string filePath = "c:\\somepath\\some.pdf";
Response.ContentType = "Application/pdf";
Response.WriteFile(filePath);
}
Hit the page in Firefox, PDF loads right up. Hit it in IE, nothing.
Just a broken puzzle icon.
Further, one of the developers on my team did the exact same thing and
it doesn't work at all. IE prompts him to save or open, which will save
the PDF (but it opens as a .aspx so he gets PDF gibberish in VS.NET if
he chooses open), and in Firefox he gets a message about the file being
corrupt.
The eventual goal is to do the same with a file on another computer (not
on the web server), so the questions are:
1)Why isn't it working properly in IE?
2)Why would it work on one machine and not another?
3)Any other tips regarding this?
Thank you very much in advance.
Scott.
--
____________________________________________
Scott C. Reynolds - Tales From the SharpSide
http://www.scottcreynolds.com
(e-mail address removed)
*****Get your SharpSide Swag!******
http://www.cafepress.com/sharpside/
***********************************