• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 556
  • 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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

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