Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 545
  • Last Modified:

Exception at System.Web.HttpResponse.End()

Hi,

I've got a problem with ASP.net. Creating a text file to save plain text to users hard drive using code like below when user clicks a button.

The exception is
at System.Threading.Thread.AbortInternal() at System.Threading.Thread.Abort(Object stateInfo) at System.Web.HttpResponse.End()
The line with exception is at "Response.End()"

The text file DOES save to users hard drive successfully, its just this exception happening which I don't like.

Help appreciated, thank-you
'response to prompt user to save.
Response.ClearContent()
Response.ContentType = "text/plain"
 
Response.AddHeader("Content-disposition", "attachment;filename=""" + filename + """")
Response.Write(theText)
Response.End()

Open in new window

0
rwallacej
Asked:
rwallacej
2 Solutions
 
Anurag AgarwalPython DeveloperCommented:
try calling Response.Flush after Response.Addheader then Response.write

Anurag
0
 
dampseyCommented:
if anuragal's solution do not work, please try the following

instead of
Respense.End()
use

Response.BufferOutput = true
Response.Flush()
Response.Close()
0
 
rwallacejAuthor Commented:
hi dampsey/anuragal,

this works now using 2nd solution. thank-you.

I have given anuragal as this started on way to getting solution

thank-you both
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now