PDA

View Full Version : Redirecting to a file.


Morgoth
04-29-2003, 11:29 PM
Hello,

I am trying to find a way in ASP to redirect a page to a file without having it sent as a binary and displayed on the browser screen. Does anyone know?

Does anyone know what I mean?

raf
04-29-2003, 11:57 PM
I don't.

Redirect to a file you don't want to display? Or don't you want to redirect clientsided?

I assume you know
response.redirect("filename")

Morgoth
04-30-2003, 01:43 AM
If I use Response.Redirect, and it will send the binary of the file to the browser and all I will see is:

PKw. ]* global.asa_OO1n!FD,Ɋ4WSmvB"4p0i޼MSI:hvbȮȊ~Qּ"_*SF<IiԊ &ˢ89{Ɉ'JwIՒL X*8b6&{߆ΐAyaP 1em:L̍% ,EfD pS.-I& R4H_};S~饞pX-gBH@8<HϹωл~'PKw. ]*  global.asaPK8R


I don't want that, I want the download to popup...

Roy Sinclair
04-30-2003, 03:59 PM
You can't use response.redirect for that, what you can do is redirect (or run it inline) to code that reads the file and writes the content to the browser.

Just use response.contenttype to set the proper mime type and then response.binarywrite to write the content to the browser window. This (http://www.microsoft.com/mind/0798/image.asp) article from MS discusses how to store and then display GIF images from a SQL database, you use the code for loading the database to read the file and the code for sending the data from the database for sending the file data while leaving out the database they have in the middle. Just make sure you set the proper mime type for the type of file (.ZIP?) you're sending and make sure that if you accept a filename as input to the page that you limit the possible files it will send or a hacker could use your page to retrieve any file the user id the page runs under would have access to.

Morgoth
04-30-2003, 08:08 PM
I tired that writebuffer way before, but, it also seems that if I set Response.Buffer = True, then it will not try to load the file in the browser, but accually allow me to download it... (when I use response.Redirect...)