Free Support Forum - aspose.com

Open a Word doc from a Virtual Directory

My MS Word docs are on a server other than the Web server and are accessed using a Virtual Directory. Permissions are set so that a link to the Word Doc will download the file. But when I try to open it with the following:

string filename = Request.QueryString["filename"];

string path = Server.MapPath("~/Manuals/");

string filePath = Path.Combine(path, filename);

Aspose.Words.Word word = new Aspose.Words.Word();

Aspose.Words.Document doc = word.Open(filePath);

It fails with the following error:

Logon failure: unknown user name or bad password.

What permissions do I need to set on what to open the file from that virtual directory?

The value in filePath returns a valid path and I can open that location from my PC.

This is the only obstacle preventing us from purchasing Aspose.Words and Aspose.PDF.

Since the Document class represents a MS Word document that should be processed by Aspose.Words, just instantiate it to get a new document object. Document has several overloaded constructors allowing to create a blank document or load it from a file or stream.

Do not use the Word class to open a document because it is obsolete.

Thank you for replying.

Using the Document class to open the MSWord doc yields the same error.

protected void Page_Load(object sender, EventArgs e)
{
string filename = Request.QueryString["filename"];
string path = Server.MapPath("~/Manuals/");
_filePath = Path.Combine(path, filename);

Document doc = null;
try {
doc = new Document(_filePath);
}
catch (Exception ex){
Response.Write(ex.Message);
Response.Write(_filePath);
}
//SendToBrowserAsPdf(doc, Page.Response);
}

Still responds with

"Logon failure: unknown user name or bad password. "

The path and file name returned from _filePath is still a valid logical path.
I saw a post about how installing on the server as opposed to simply including the dlls fixes some errors so I did that, but the error still happens.

As you can see, the Document can be loaded from a stream. So if you manage to load your file to a FileStream you can then start Aspose.Words.Document from this stream.

I mean to say that the problem is unrelated to Aspose.Words. You need to find a way to load your file with .Net somehow.

If the document is on your server, then as long as you get the permissions right it will load. You need to remember that the ASP.NET application runs under some user account (usually "aspnet"). You need to make sure this account has at least read permissions to the folder and the document.

Sorry I missed that you document is on a different server. In this case you cannot use MapPath I suppose. Use this example to load a document from a URI: http://www.aspose.com/Community/Forums/6485/ShowPost.aspx

romank wrote:
Sorry I missed that you document is on a different server. In this case you cannot use MapPath I suppose. Use this example to load a document from a URI: (deleted link because the forum got mad)

That round-about method looks like it might work as first, but after playing with it, I discovered it cannot handle a relative path. Hard code it? nah. There may be another work-around but I'm not sure it'll be worth it.

But as miklovan pointed out, it's a .Net permisisons issue now... and the start of another tail-chasing round of MSFT "features" stepping on each other. Angry [:@]

Thanks for your time, guys.