Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel Automation

Status
Not open for further replies.

vvlad

Programmer
May 27, 2002
151
DE
Hi,

I've written an application that processes some Excel files. Works fine on my local machine, but on the server I get the following error:

--------------------
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 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 <identity impersonate=&quot;true&quot;/>, the identity will be the anonymous user (typically IUSR_MACHINENAME) or the authenticated request user.

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

The line that causes the error is:
xlApp = new Excel.ApplicationClass();

I've tried everything I knew with that @%$&@ ASPNET account, but nothing worked. Can someone help?

Thanks,


vlad
 
Thanks for answering, SHelton.

Just for the record...
Asigning rights to ASPNET on the server did not bring anything, but I solved the problem by adding this line in the web.config file:

<identity impersonate=&quot;true&quot; />

If someone knows a better way to do it, please let me know.

vlad
 
You know, of course, that Excel is not a server app?

If you have multiple requests come in to create your .xls file, Excel may behave oddly. It would be best to serialize your requests (in the sense of processing them in order, one at a time). So if you were to write a NT Service to run your Excel object, and have it get it's work packages from a MSMQ queue, that would prevent any future problems.

Chip H.


If you want to get the best response to a question, please check out FAQ222-2244 first
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top