Free Support Forum -

Export page to word I am getting error please give suggestion

Hi all

I written this below code

string url = ConfigurationManager.AppSettings["ApplicationRoot"].ToString() + "/ASPX/PreviewToWord.aspx?ProjectInventoryID=48&ProjectID=30";

//Prepare the web page we will be asking for

HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);

request.Method = "GET";

request.ContentType = "application/msword";
request.UserAgent = "Mozilla/4.0+(compatible;+MSIE+5.01;+Windows+NT+5.0";

//Execute the request

HttpWebResponse response = (HttpWebResponse)request.GetResponse();

//We will read data via the response stream

Stream resStream = response.GetResponseStream();

//Write content into the MemoryStream

BinaryReader resReader = new BinaryReader(resStream);

MemoryStream docStream = new MemoryStream(resReader.ReadBytes((int)response.ContentLength));

Document doc = new Document(docStream );

//Save document

Here I am getting two errors one is : The current HttpRequest is unauthorised ...

In application I am using windows authontication if any body access url they shold give username password .

But here how can i get page streeam ?

And I tried one more way

Document doc = new Document("test.html");

//Save document


Here the word file is not asking save dialogue its saving some location directly . like file download dialogue box its not showing .

and this time i am getting one more error in saved word file

Evaluation Only. Created with Aspose.Words. Copyright 2003-2008 Aspose Pty Ltd.

This document was truncated here because it was created using Aspose.Words in Evaluation Mode

Thanks advance


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

Thanks for your request.

1. This error occurs because you is not authorized and server returns 401 error. You can try specifying Credentials for this request. See the following code snippet.

request.Credentials = new NetworkCredential("user", "password");

Or send the credentials from the current user context (the user that started the application).

request.Credentials = System.Net.CredentialCache.DefaultCredentials;

2. “Evaluation Only. Created with Aspose.Words. Copyright….” This is evaluation message from Aspose.Words. This occurs because you are using evaluation version. Please see the following link for more information.

Best regards.