473,387 Members | 1,899 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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

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
4 8169
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

19
by: dmiller23462 | last post by:
Hi guys....I have absolutely NO IDEA what I'm doing with Javascript but my end result is I need two text boxes to stay hidden until a particular option is selected....I've cobbled together the...
2
by: R.A. | last post by:
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...
4
by: Nathan Sokalski | last post by:
I want to give visitors to my site the option of downloading a generated ..txt file by clicking a button. I know how to generate text files, but how do I cause the browser to pop up one of those...
4
by: Blaine | last post by:
Does anyone know how I can hide a form from the TaskManager? I've set the ShowInTaskbar to False, but when using Alt-TAB to switch between applications, it appears as a blank icon. I can set it...
2
by: zhangyl | last post by:
I use a WebBrowser control to open an office Document in my form , but every time when I open a file, there a dialogbox named "File download" showed asking "Whether you want open or save this...
13
by: nokan | last post by:
Hello! I'm trying to secure pdf-files from users that are not logged in on a site. What I have tried now is to make a .htaccess file in the directory where the pdf's are with "deny from all"...
6
by: Norman | last post by:
Hello, I have a working Show / Hide form, that works on FF, but what I would like to do is to be able to display one part when a user clicks on one radio button and display another part when the...
4
by: =?Utf-8?B?U3JpZGhhcg==?= | last post by:
Hi, Is it possible to Hide/Show controls during a callback? I have a radio button list that does the callback. When it does the callback I need to refresh the grid to reflect the selected value...
10
by: sara | last post by:
Hi - Is it possible to hide the detail section of a report at run time? I have a report that prints all details, with summary lines. The user would like the report ALSO with just summary lines....
3
by: jmeyer5csc | last post by:
i am using jquery to display a working... div to show the user that the query is doing something. to show.... Sys.Application.add_init(function() { ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.