The response is closed after the document is exported.

I am trying to export a Word document to Response using ASP.Net. Therefore, I achieved this goal with this code.

Response.Clear();
Response.ClearHeaders();
Response.ClearContent();
Response.ContentEncoding = Encoding.UTF8;
Response.Charset = "UTF-8";
Response.Buffer = true;

this.EnableViewState = false;
Response.ContentType = "application/msword";
Response.AddHeader("content-disposition", "attachment;filename=ExportedData" + Guid.NewGuid().ToString().Remove(5) + ".docx");

var wordData = this.RequestService.ExportToWord(this.RequestItem);

Response.BinaryWrite(wordData);
Response.Flush();

//Response.Clear();
//Response.End();
//Response.Close();
//RedirectToSamePage();
//Response.Flush();

But the problem is that when the user exports this page as a text document, the other functions of the page disappear. For example, you cannot click on another ASP control because the end of the Response object, kills the ASP, controls the connection to the DLL. So, as you can see from the comments, I called some functions of the Response object, but still I can not control other ASP controls that will work after the export operation. So how can I do this?

Thanks in advance.

+3
source share
2 answers

, . , , Word.

:

  • , Word
  • iframe ( ) , Word. , .
+3

. aspx response.redirect , window.location, . , , .

, , . .

0

All Articles