473,378 Members | 1,454 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,378 software developers and data experts.

download a file from a web page: first time works, next times not

Hi all

on a page aspx of my web application (vs2005, .net 2.0), I have an
imagebutton

Its click event looks like this:

filename = createFile(); //create a file on server filesystem

if (File.Exists(filename))
{
Response.Clear();
Response.ContentType = "application/x-download";
Response.AddHeader("Content-disposition", "attachment;filename=" +
Path.GetFileName(filename));
Response.WriteFile(filename);
Response.End();
}

First time user click on the image and download the file -all done, all
ok...

If user retry to click on the image an exception is raised on the row
"Response.End()". The exception is not readable. The message (not the
Message field, but visual studio message) is "Impossible evaluate the
expression because the code is optimized or a native frame is at the start
of the calls stack"

Can Someone tell me how solve this problem?

Thank you all
Fabio

Aug 17 '08 #1
2 904
Fabio Mastria wrote:
Hi all

But you read me? do you receive this mail ? Or there's some problem in my
windows mail configuration?

Aug 18 '08 #2
On Aug 17, 6:47 pm, "Fabio Mastria" <dipie...@mastriaconsultants.com>
wrote:
Hi all

on a page aspx of my web application (vs2005, .net 2.0), I have an
imagebutton

Its click event looks like this:

filename = createFile(); //create a file on server filesystem

if (File.Exists(filename))
{
Response.Clear();
Response.ContentType = "application/x-download";
Response.AddHeader("Content-disposition", "attachment;filename=" +
Path.GetFileName(filename));
Response.WriteFile(filename);
Response.End();

}

First time user click on the image and download the file -all done, all
ok...

If user retry to click on the image an exception is raised on the row
"Response.End()". The exception is not readable. The message (not the
Message field, but visual studio message) is "Impossible evaluate the
expression because the code is optimized or a native frame is at the start
of the calls stack"

Can Someone tell me how solve this problem?

Thank you all
Fabio
Hello Fabio:
Maybe there is some problem in your createFile function, and without
code, i can't help. But I sugest you that if the only use of the file
is for sending to client, create it in memory, what is faster and
allow you to cache it in session fields.
Best regards.
Aug 19 '08 #3

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

Similar topics

5
by: Roman | last post by:
I'm using a single css for 3 different layouts in my site, where everything is the same, but header images. Recently I've run a "download times" test and it turned out that my css is calling the 3...
3
by: Skwish | last post by:
Hi, I would like to download all the files from a folder (of various types i.e. ..txt, .dll, .dat, etc.). I tried Dim MyDir As IO.Directory Dim path As String = Me.MapPath(".") & "\Data" Dim...
6
by: Jatin | last post by:
Hey Guys I have a web application that allows users to download files. But the files are not hosted on the webserver. The files are stored on external servers and are referenced by a URL/URI....
18
by: Mark | last post by:
Hello. I am looking for a way to download and cache a web page that the user has not yet requested, and write the web page to the browser cache without displaying it. My intention is to improve...
2
by: Jobs | last post by:
Download the JAVA , .NET and SQL Server interview with answers Download the JAVA , .NET and SQL Server interview sheet and rate yourself. This will help you judge yourself are you really worth of...
7
by: Sheldon Glickler | last post by:
I have a set of jpg files on a page. I want to give the user the option to downloadd all of them at once. What is the code to do that? It must exist because many times users are presented with a...
1
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
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: 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...

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.