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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Access Denied When Trying to Create Excel Object

Status
Not open for further replies.

BigRedTexas

Programmer
Mar 14, 2002
22
US
I have a simple button on my asp.net app that runs some code to create an excel workbook (object). I am getting the following error message. Can anyone help?

"Exception Details: System.UnauthorizedAccessException: Access is denied.

The ASP.NET process is not authorized to access the requested resource. For security reasons the default ASP.NET process identity is '{machinename}\ASPNET', which has limited privileges. Consider granting access rights to the resource to the ASP.NET process identity.

To grant ASP.NET write access to a file, right-click the file in Explorer, choose "Properties" and select the Security tab. Click "Add" to add the "{machinename}\ASPNET" user. Highlight the ASP.NET account, and check the Write box in the Allow column."
 
Hey Big Red (why is everything associated with Texas BIG?)
;)

All asp.net processes actually run under a system account called aspnet. Think of it as its own user, which has access rights and privelages just like any other user.

By default, the aspnet user has very low security access, especially when it comes to writing/creating/reading files that are outside of the folder. If you want it to do this sort of thing in a particular folder or file, you actually have to follow the last paragraph that you posted (about right-clicking the file in explorer, etc.) to grant the aspnet user access rights.

Since you're trying to open an excel app, I'm guessing you'll probably want to grant the aspnet user access to wherever your actual excel.exe file is. In theory, this should solve the problem for ya.
:)

Let me know if you need anything else

Big Blue Jack
;)
 
Hey Red, a couple of other things about the aspnet account:

- the actual account name is aspnet_wp account

- you don't have to run your asp.net processes under the default account. If you'd like to run it under a different account (like your own windows account, or one you create), its very easy. Search for machine.config on your computer (its burried in your winnt\Microsoft.NET\Framework\1.0.blahblahversion\CONFIG
folder) and open it. Search the document for a process model tag (it'll be after a whole bunch of commented out documentation, and before the web control tags). In the process model tag, you can set the username and password to be a different account. Voila: your asp.net processes can now be run under any account you wish.

Now, you may be wondering why you'd want to do that. I mean, where would this come into play? Well, lets say (this is my case) you have 4 workstations and 1 server, all on a domain. The server has a SQL Server using windows authentication, which only allows the users to have access to the database. For my local .net dll's to run connected to the sql server, I need to have the process model set the user account for the processes to my account, since its one of only a few accounts the sql server will recognize.

Just remembered this after I posted the first response, sorry about all the text.
:)

Jack
 
The problem I have here is that I'm trying to create a NEW Excel workbook. Therefore, there's nothing to set rights to?

I'm very new to .NET, so you'll have to give me some slack.

Thanks,
Scott
 
np Scott, its taken me 4 months of non-stop coding to get my head around .NET
:)

Tell me if I'm wrong here:
You want your asp.net program to start a new workbook session in Xhell on the client machine, right?

oh crap...stupid me, that IS a problem! on your own machine that would work (like, if you were going to test your app on your machine, you could make an Xhell document pop up assuming that you were running IIS locally and you could then set the machine permissions to allow your asp.net app access to your version of Xhell). But the asp.net access rights won't mean squat on the client side of things.
:(

K, well with that said, I don't think what you want to do can be done. For the user to open a new workbook on their machine, they would either a) need a copy of Xhell on their machine or b) have copies of the dll's that can create a workbook, which I'm pretty sure they'd only have if they had a copy of Xhell on their machine.

And since all asp.net gives back is html to the client, there is no actual "live" web-version of Xhell that you can use. You could create a table and code the heck out of it ot try and duplicate funtionality, but thats a pretty big job. hmmmm.... Why do they have to open a workbook? Just wondering in case there's maybe another way to tackle this without Xhell.

Jack
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top