473,516 Members | 3,456 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 8183
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
6857
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 JavaScript in this code from a couple different sites but I'm not 100% sure what each line is doing...This is the ASP code that I'm using for the...
2
330
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 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...
4
2315
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 dialog boxes that says something like "Do you want to download FILEX.txt?" I want the user to be able to download the file rather than have the file...
4
4370
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 as a SizableToolWindow, but then I no longer have the minimize button on the caption. Is there a way to mimic a (FormBorder) sizable tool window...
2
1859
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 file?", how can I hide it? Actually, when opening an office file embeded in IE, there also show this dialog, How can I do it?
13
1812
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" which stops everyone from downloading them. Then in the member-area when a user wants to download a pdf a php-script copies the pdf-file from the...
6
4178
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 user clicks on the second radio button - here is the code which just shows / hides the whole form: <script type="text/javascript"> <!-- var...
4
2275
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 in the radio button. Also I need to hide some check boxes based on the selected value. The checkboxes and radiobuttons are both server controls....
10
11730
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. It seems the simplest thing is to run the code (see below) once with the detail section showing, and a second time hiding the detail section. I...
3
4015
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() { $addHandler($get('ctl00_ContentPlaceHolder1_LinkButtonQuickReport'), 'click', function() { $('#working').show(); }); }); to hide...
0
7273
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7182
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7405
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7136
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
5712
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
3265
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3252
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
823
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
487
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.