473,385 Members | 1,622 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,385 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 8168
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.