Hi there,
I am trying to use respose.writefile to display a PDf but I keep getting this error message. 'HTTP://web2/brochure/21xx/2101bro.pdf' is not a valid virtual path.
I know I can put that URL into a web browser and see the PDF so that doesn't seem to be the problem.
This is the code I am using...
//Set the appropriate ContentType.
Response.ContentType = "Application/pdf";
//Write the file directly to the HTTP content output stream.
//For testing lets try a static URL that we know is there.
//this will have to become dynamic when it works
string brochureURL = "HTTP://web2/brochure/21xx/2101bro.pdf";
Response.WriteFile(brochureURL);
Response.End();
I am missing something - I don't know if it is the code or the IIS config. Can some point me in th right direction?
Thanks a lot!Hi,
Try this,
Dim oStream As MemoryStream
oStream = CType("HTTP://web2/brochure/21xx/2101bro.pdf", MemoryStream)
Response.Clear()
Response.Buffer = True
Response.ContentType = contentType
Response.AddHeader("Content-Disposition", "attachment;filename=File.PDF")
Response.BinaryWrite(oStream.ToArray())
Response.End()
oStream.Close()
oStream.Dispose()
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment