Free Support Forum -

Problems running aspose.words and aspose.pdf


I am writing a simple app on our server to test your .net components (aspose.word and aspose.pdf). The app reads a MS Word file and converts it to .pdf format and saves it to disk at the required location. I was able to run this app on my development ASP server. It run ok.

When migrating the app to the production server, I got the following error:

Server Error in '/WordToPDF' Application.

Access to the path 'C:\WINDOWS\system32\Document.ConvertToPdf Out.xml' is denied.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.UnauthorizedAccessException: Access to the path 'C:\WINDOWS\system32\Document.ConvertToPdf Out.xml' is denied.

ASP.NET is not authorized to access the requested resource. Consider granting access rights to the resource to the ASP.NET request identity. ASP.NET has a base process identity (typically {MACHINE}\ASPNET on IIS 5 or Network Service on IIS 6) that is used if the application is not impersonating. If the application is impersonating via , the identity will be the anonymous user (typically IUSR_MACHINENAME) or the authenticated request user.

To grant ASP.NET access to a file, right-click the file in Explorer, choose "Properties" and select the Security tab. Click "Add" to add the appropriate user or group. Highlight the ASP.NET account, and check the boxes for the desired access.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[UnauthorizedAccessException: Access to the path 'C:\WINDOWS\system32\Document.ConvertToPdf Out.xml' is denied.]
System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) +2014707
System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy) +998
System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options) +115
Aspose.Words.Document.Save(String fileName, SaveFormat fileFormat) +56
_Default.btnConvert_Click(Object sender, EventArgs e) +185
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +105
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +107
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5102

Version Information: Microsoft .NET Framework Version:2.0.50727.42; ASP.NET Version:2.0.50727.42

Enclosed is my code iun a MS Word file for your kind review. You can easily paste it into the Visual Studio text editor to test it if you so desire..

Please provide some technical support, suggesions or explanation on the cause of this problem. Your assistance is sincerely appreciated.

Thank you.

Rich -

Hey Rich,

Thank you for the post and for all of the information. Based on the post it does sound like a permission issue with the ASP.NET user account; however, I am going to defer to the Aspose.Words development team for an endepth answer. I am going to move this post to the Aspose.Words forum and the development team should follow up shortly. Please be sure to let me know if there is any way that I can assist further and I will be more than glad to.

Mr. Cooper:

Thank you for your reply.

I appreciate your follow up.

Rich -

From what I see in the error log I can derive that you are trying to write into 'C:\WINDOWS\system32\' directory from your application. Your ASP.NET application of course does not have a permission to do that. And it will not be a good idea to grant the ASPNET user account the permission to write into the system directories. The better solution is to use an application directory, subdirectory or some other dedicated directory to write work files for you application.

For example, you can use MapPath method to get your application directory path from within your application. Please don't forget to set all necessary permissions and configuration settings for your application in IIS.

Best regards,