Free Support Forum - aspose.com

Newbie having problem opening file in browser

Hello,

I have Aspose evaluation copy. In my code I have had success opening a file using the following code placed in the Page_Load event:

string MyDir = "C:\\myDir\\TermSheet\\Doc\\";

Document doc = new Document(MyDir + "66C7F9F82E664A0FAF4BE52A07842922.doc");

doc.Save("Report Out.doc", SaveFormat.Doc, SaveType.OpenInBrowser, Response);

However if I palce the same code in the click event of a button the document does not display & I get an error icon displayed with the message Sys.Webforms.PageRequestManagerParseErrorException.

Can anyone suggest a way to fix this?

Thanks

daforga

Hi

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your request. It is difficult to say what the problem is. Maybe you do not have permissions to read from the specified folder. Maybe you should create subfolder in the root folder of your web application and store all documents there. Then you can open documents from this folder using Server.MapPath. For example see the following code:

// Open document.

Document doc = new Document(Server.MapPath(@"documents/mydoc.doc"));

Hope this helps.

Best regards.