473,396 Members | 2,034 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,396 software developers and data experts.

Problem downloading csv file

Hi All,

I have an asp.net 1.1 application that includes a rudimentary contacts database that must support importing from and exporting to Outlook. The file upload part works fine, but I'm having trouble allowing users to download their contacts so that they can import into Outlook.

I am using a csv file to exchange the data been our system and Outlook. For security reasons I have avoided writing user's contacts to a csv file on the server and then providing a link to it, and have instead tried to create the required output and stream it directly to their browser.

The code that creates the csv file is contained in a class that implements the IHttpHandler interface. It sets the following headers:
Context.Response.ContentType = "text/comma-separated-values"
Context.Response.AppendHeader("Content-Disposition", "attachment; filename=""Contacts.csv""")

It also queries the database and loops through the records using response.write statements to create the required output.

The application's web.config file has the appropriate <httpHandlers> element, and the application has been configured to handle .csv files with the aspnet_isapi.dll ISAPI extension.

This setup works exactly the way I want it to on the development server: The application redirects the user to a file called Contacts.csv and they are prompted to save the file to their hard drive with the name Contacts.csv. The file is then downloaded successfully.

On our production server the user is prompted to save the file. However after clicking the save button the users receive the following error:

Internet Explorer cannot download Contacts.csv from ServerName.

Internet Explorer was not able to open this Internet Site. The requested site is either unavailable or cannot be found. Please try again later.

Any ideas about what could be causing the error?

Regards,

Guy Penfold

Nov 18 '05 #1
3 1975
Do you have something in the IIS log for this request ?

Does it work when streaming directly from an ASPX page ?

"Guy Penfold" <an*******@discussions.microsoft.com> a écrit dans le message
de news:B4**********************************@microsof t.com...
Hi All,

I have an asp.net 1.1 application that includes a rudimentary contacts database that must support importing from and exporting to Outlook. The file
upload part works fine, but I'm having trouble allowing users to download
their contacts so that they can import into Outlook.
I am using a csv file to exchange the data been our system and Outlook. For security reasons I have avoided writing user's contacts to a csv file on
the server and then providing a link to it, and have instead tried to create
the required output and stream it directly to their browser.
The code that creates the csv file is contained in a class that implements the IHttpHandler interface. It sets the following headers: Context.Response.ContentType = "text/comma-separated-values"
Context.Response.AppendHeader("Content-Disposition", "attachment; filename=""Contacts.csv""")
It also queries the database and loops through the records using response.write statements to create the required output.
The application's web.config file has the appropriate <httpHandlers> element, and the application has been configured to handle .csv files with
the aspnet_isapi.dll ISAPI extension.
This setup works exactly the way I want it to on the development server: The application redirects the user to a file called Contacts.csv and they
are prompted to save the file to their hard drive with the name
Contacts.csv. The file is then downloaded successfully.
On our production server the user is prompted to save the file. However after clicking the save button the users receive the following error:
Internet Explorer cannot download Contacts.csv from ServerName.

Internet Explorer was not able to open this Internet Site. The requested site is either unavailable or cannot be found. Please try again later.
Any ideas about what could be causing the error?

Regards,

Guy Penfold

Nov 18 '05 #2
Thanks for your response,

The log file indicates that the requests are being handled ok. The server returns a 200 code and the size of the response is as expected

It doesn't work when streaming directly from an .aspx page either. This was the original approach that I took and I only switched to using an http handler when I ran into problems

Guy
Nov 18 '05 #3
Could it be an execution error during the request ?

I never ran into such a problem when streaming files. You could comment the
header to just display the file. It would allow to check if the whole
content is streamed or if it's cut before the expected end...

The only difference I see is that I'm calling Response.Clear to make sure
the buffer is cleared and I'm not using " to enclose the filename.

Patrice
"Guy Penfold" <an*******@discussions.microsoft.com> a écrit dans le message
de news:81**********************************@microsof t.com...
Thanks for your response,

The log file indicates that the requests are being handled ok. The server returns a 200 code and the size of the response is as expected.
It doesn't work when streaming directly from an .aspx page either. This was the original approach that I took and I only switched to using an http
handler when I ran into problems.
Guy

Nov 18 '05 #4

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

Similar topics

2
by: Bala | last post by:
Hi I am trying to download the PDF files from my webserver using ASP.Net. All my files are stored at F Drive on webserver. Like this F:\Main Folder\Sub Folder\Files\File1.pdf I am...
1
by: just.starting | last post by:
Hi, My dot net client downloads files and checks for any new files time to time. The server is apache2.0.53 server. So what happens is that my file download thing works fine if I dont try to call...
5
by: fniles | last post by:
We created an ActiveX control and marked it as safe for scripting using Implements IObjectSafety. We then created a CAB file and signed it using Verisign. We also created a license file (LPK file)...
0
by: just.starting | last post by:
I am having problem while downloading files from an apache server2.0.53 with php4.3.10.While downloading some files it generally stops after downloading some specific amount and then stops...
102
by: hug | last post by:
www.webmaster, was suggested that this ng could be a better place.] I've updated my test server to handle if-modified-since. I've noticed that the (old copies I run of) IE and Netscape seem...
1
by: alex23 | last post by:
Hey everyone, I'm trying to install setuptools on a work PC behind an NTLM firewall. I've tried to use APS as recommended but am still unable to have anything other than IE talk through...
1
by: Paul | last post by:
I just installed php 4.4 with apache 2.0 on WIN XP. All is working so far. From: the prompt, I type: go-pear and here's what I get: Loading zlib: ok Using local package: PEAR-stable......ok...
6
by: cyusman | last post by:
Hi, We have just moved our application to a new webfarm server environment which utilizing hardware load balancing, SSL off-loading and HTTP compression off-loading.My application is running on...
1
by: Muddasir | last post by:
Hello everyone. I am facing problem in downloading .xls file. I generate report and save data in excel sheet on server. and once user click the 'save data in excel format', an excel sheet is...
1
by: shahidrasul | last post by:
i want to download a file which user select from gridview, downloading is completing without problem but after download i want to refresh my page because i do some changes in db . but when...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
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
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
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...
0
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
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,...

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.