Free Support Forum - aspose.com

Is there anyway to avoid response ending?

My problem is that i am executing the command doc.Save(System.IO.Path.GetFileName(strWordDoc), Aspose.Word.SaveFormat.FormatDocument, Aspose.Word.SaveType.OpenInWord, Me.Response) in my page load.

But once the word document opens in word, any changes made in the page load are ignored.

for example, code just before the doc.save command loads a list. This list is never loaded because i guess the response got redirected to word.

Is there anyway to open the word document in word without loosing my response?

Thanks

Gavin Duffy

You can make the client’s browser open the resulting document in another window. To view how it can be done check SubmitBtn_Click handler in Aspose.Word.Demos project.

Opening word in a browser window is not practical as i loose all word menus and toolbars

My last 2 parameters in the save command are Aspose.Word.SaveType.OpenInWord, Me.Response

I need to stop the response from cancelling all code executed in the callling routine.

calling a popup to execute the open in word option would just leave blank popup's everywhere.

Is there no alternative to the me.response parameter?

You can save the document in a temporary file on server and send a script in your response which should open the saved file in the next round trip.

Something like

""

Hi Vladimir

That will still open the word document inside an IE browser window. This is a no can do because word has no functionality when opened this way. See my previous post.

I need to open the document in word without loosing my response.

Thanks

Gavin

From what I can understand you cannot send both a Word document and also a meaningful HTML in the same response to the browser. Basically the content header specifies what the response contains. If you send HTML, the content specifies the response contains HTML. If you send a document file using Document.Save(...,HttpResponse), then content type is set to a Word document and a document is streamed to the response.

I don't think we have enough experience at Aspose to consult on ASP.NET questions. Maybe you should reconsider your design, our customers never had problems, probably because they were not trying to achieve what you are trying to. Please seek some expert ASP.NET advice.

When Document.Save(...,HttpResponse) is called, Aspose.Word does not end the response. It merely sets the response headers and writes the document. So technically speaking your code after calling Document.Save is executed and HTML is written, but it is appended after the Word file in the response and probably simply ignored on the client end.

Our application does the same thing … it leaves a popup window open after producing a word or other document.



i don’t know how to avoid the dead popup windows, but it must be possible - because …



I just went to my online broker’s site, and downloaded a price history
file, and voila, it produced a spreadsheet – without any extra
windows left behind.



If I find out just how they did it will let you know …



Regards

David

In our ASP.NET demo applications no dead popup windows are shown.

If you attach your application I can look through it and maybe help you more.

Hi David

I never got that far as opening multiple windows is not a practical solution for me. Not to mention the number of popup blockers out there today.

My problem is that unlike what aspose says, scripting a word document to open in a page load event will kill the page load process itself. You can only open a word document by either having a dedicated event such as a button click or scripting a popup.

As for your problem, a simple javascript timer to close the window after a few seconds is one workaround. I'm suprised a response.redirect in the page load would not also close the window.

For now, i simply force my clients to take an extra step when they want to view the document, namly clicking a view button.

Gavin

The demos open in a browser window, no word functionality. To open the doc in word, you are have to add the last two parameters including the response. Doing this, back to orig problem.

There needs to be a way to open on a page load for example without killing the response.

I figured out how my broker sends the price history file without
leaving a dead popup window behind. But it is not the solution I was
hoping for.



All they do is to send the CSV file in the current browser window. The
browser gives the options of Open or Save. If I choose Open, the
spreadsheet opens within the current window. Actually it is in
the current frame, so the navigation is still available from the other
frame(s).



Of course if I choose Save, it goes to disk and I get the desired result.



Because the application cannot know in advance whether the user will
choose Open or Save, I think we are stuck with this limitation –
either always create a Popup window (with possibility of leaving it
behind, and also hassle of popup blockers), or always open in current
window, and allow for possibility of Word document being shown in the
current window. With frames you can still get navigation (but of
course, may not want frames for other reasons).



In the Demo, Aspose have added a checkbox “Open in New Browser Window (requires popup blockers
disabled)”. I reckon this is the best solution.



Edit: Gavin, if your users are not being offered the choice of Open or
Save, that is a per-user setting in Internet Explorer under Tools -
Options (and also the Confrm Open after Download setting in Windows
Explorer / File Types can affect this).