Is there a way to hide the url when giving download option to a user?

R

R.A.

Hi

In the web site I work on I give the users an option to download files from
the web server. They click a button and I use the
Response.Redirect("filename.exe"). The problem is that the user migth see
the downloaded file url. Is there a way to hide the downloaded file url (it
shows in the ie taskbar). Server.Transfer doesn't work for this.


Thanks
 
K

Ken Cox [Microsoft MVP]

You can use Response.WriteFile to send a file from the file system without
telling the browser its path. Call the routine from the onclick event of a
server control.

' Calculate the filename by taking everything after the final slash
strPDFname = strFilepath.Substring(strFilepath.LastIndexOf("/")
+ 1)
strFileExtension =
strFilepath.Substring(strFilepath.LastIndexOf(".") + 1)

' Set up the response headers for a PDF download
Response.Clear()
Response.ClearHeaders()
Response.ClearContent()

' Create a suggested filenname for the downloaded document
(short - not the whole path)
Response.AddHeader("Content-Disposition", "attachment;filename="
& strPDFname)

'Write the file to the browser and end the HTML content
Response.WriteFile(Server.MapPath(strFilepath))
Response.End()
 
K

Kevin Spencer

You could always use System.IO to open the file from a location that is not
available to the web server and write it back to the client.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top