By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,478 Members | 1,833 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,478 IT Pros & Developers. It's quick & easy.

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

P: n/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
Nov 18 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
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()

"R.A." <te**@citsecure.com> wrote in message
news:el**************@TK2MSFTNGP12.phx.gbl...
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


Nov 18 '05 #2

P: n/a
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()

"R.A." <te**@citsecure.com> wrote in message
news:el**************@TK2MSFTNGP12.phx.gbl...
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


Nov 18 '05 #3

P: n/a
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.

"R.A." <te**@citsecure.com> wrote in message
news:el**************@TK2MSFTNGP12.phx.gbl...
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

Nov 18 '05 #4

P: n/a
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.

"R.A." <te**@citsecure.com> wrote in message
news:el**************@TK2MSFTNGP12.phx.gbl...
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

Nov 18 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.