473,513 Members | 2,505 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

File Downloads

I have a simple file download button that when clicked opens a window with a
file download dialog prompting a user to save in csv or xls format. The code
works fine locally. (In debug mode there is an exception thrown on the
response.end line) but once on the server the page displays and then closes
immediately. Below is the relevant code. Has anyone encountered this before?

Response.Clear()
HttpContext.Current.Response.BufferOutput = True
HttpContext.Current.Response.AppendHeader("Content-Disposition",
String.Format("attachment; filename={0}", fileName))
HttpContext.Current.Response.ContentType = outType
Dim encoding As New System.Text.ASCIIEncoding
HttpContext.Current.Response.BinaryWrite(encoding. GetBytes(outString))
HttpContext.Current.Response.Flush()
HttpContext.Current.Response.End()
Oct 17 '08 #1
1 1240
I believe this is a security issue, but am having trouble resolving it. What
happens is that if I type in the server name in my browser, the download
works as expected. However, if I type in the domain name, the temp file never
gets written to the directory. For what account should I give permissions for
this. Does anyone know why this wouldn't work for both. It is the same exact
server.
"Erica" wrote:
I have a simple file download button that when clicked opens a window with a
file download dialog prompting a user to save in csv or xls format. The code
works fine locally. (In debug mode there is an exception thrown on the
response.end line) but once on the server the page displays and then closes
immediately. Below is the relevant code. Has anyone encountered this before?

Response.Clear()
HttpContext.Current.Response.BufferOutput = True
HttpContext.Current.Response.AppendHeader("Content-Disposition",
String.Format("attachment; filename={0}", fileName))
HttpContext.Current.Response.ContentType = outType
Dim encoding As New System.Text.ASCIIEncoding
HttpContext.Current.Response.BinaryWrite(encoding. GetBytes(outString))
HttpContext.Current.Response.Flush()
HttpContext.Current.Response.End()
Oct 20 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
6083
by: Brandon Walters | last post by:
I wrote a file download module for my website. The reason for the file download module is that my website downloads work on a credit based system. So I need to keep track of and limit daily...
10
4732
by: StevePBurgess | last post by:
I would like to make my downloads section unbrowsable (to users) but accessible to scripts. Can I deliver a file to a browser without linking to it's URL so that I can deliver files...
1
1831
by: Jeff Cooper | last post by:
Hey there folks, I have a link on a page which I would like to point to string that's downloaded as a file -- a *.tab file to be exact. The link points to a file (download.aspx) which contains...
7
3373
by: Mustafa Rabie | last post by:
Hi All, I want to add autodownload like all the one in Downloads.com. When u click download now link it redirects you to a page that the file downloads the application after the page is loaded....
10
2704
by: Atley | last post by:
I am trying to make sure that an MDB is not in use and then delete it. If it is in use, I want to automatically disconnect all the users and then delete the file. Any suggestions are welcome.
16
3223
by: matt | last post by:
I have used some free code for listing files for download, but I want to send an email to the administrator when the file has been downloaded. I have got some code in here that does it, but it will...
1
1594
by: CodeMonkey | last post by:
Hi all, I have an ASP .NET 2.0 project with the following path on my dev machine: D:\Profiles\MyUsername\My Documents\Visual Studio 2005\Projects \abcWebSite2007\abcWebSite2007\Somefile.aspx ...
21
2436
nathj
by: nathj | last post by:
Hi, I am currently working on a new site that offers various files for download. The file information is stored in a MySQL database and the page is produced in PHP depending on how the user got...
7
2798
by: =?Utf-8?B?QU9UWCBTYW4gQW50b25pbw==?= | last post by:
Hi, I have been using the code (some of it has been removed for simplicity) below to allow authenticated (using ASP.NET membership database) users to get a file from their archive area. It...
1
47358
KevinADC
by: KevinADC | last post by:
Note: You may skip to the end of the article if all you want is the perl code. Introduction Many websites have a form or a link you can use to download a file. You click a form button or click...
0
7260
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,...
0
7161
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
7539
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...
0
7525
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5686
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,...
1
5089
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
3234
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...
0
1596
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
456
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...

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.