|
-
Mar 23rd, 2003, 11:53 AM
#1
Thread Starter
Addicted Member
UnauthorizedAccessException: Access denied.
I searched this forum but didn't find an answer, which really surprises me.
In my ANP.NET code, I am trying to write to a file, but am getting an error:
Access to the path "c:\inetpub\wwwroot\ASPNutshell\Blog6-7b\Blog.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:\inetpub\wwwroot\ASPNutshell\Blog6-7b\Blog.xml" 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.
Well, the message is wrong. There is no security tab in the properties window accessed through Explorer. My searchnig revealed that you have to change it in IIS, but apparently I don't know how to do that. I checked the write box on the Files tab in the properties window, but that doesn't seem to do it. I also granted write privileges to the application directory but that didn't work either.
The problem is I don't really know IIS, so any pointers you can give me will be great. Also, are there any good resources on the inner workings of IIS?
Thanks.
-
Mar 27th, 2003, 10:50 AM
#2
Thread Starter
Addicted Member
OK, let's try this again. I have created a one-line program web app:
Code:
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
File.Create(@"C:\Inetpub\wwwroot\ASPNutshell\WriteFileExp\testFile.txt");
}
When I run the program, I get the following error:
Access to the path "C:\Inetpub\wwwroot\ASPNutshell\WriteFileExp\testFile.txt" 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:\Inetpub\wwwroot\ASPNutshell\WriteFileExp\testFile.txt" is denied.
Surely someone around here has tried to create a file in ASP.NET. Even if someone says they tried this and it works, it would give me some direction...
-
Mar 27th, 2003, 10:53 AM
#3
Sounds like your harddrive is setup as a Fat32 partitioning. You need NTFS setup to set permissions.
-
Mar 27th, 2003, 11:20 AM
#4
Thread Starter
Addicted Member
No....The properties tab says File System is NTFS.
-
Mar 27th, 2003, 12:10 PM
#5
Frenzied Member
Try this. In the user password console, give the aspnet account write privilege. If that does'nt work, open the web.config file and set impersonate to true.
Dont gain the world and lose your soul
-
Mar 27th, 2003, 12:15 PM
#6
problem with impersonate is that if the ASPNET account doesnt have permission, then impersonating it wont do much good would it?
that is strange that the Security tab doesnt show up, it should if you are on an NTFS setup.
-
Mar 27th, 2003, 12:34 PM
#7
Thread Starter
Addicted Member
Originally posted by DevGrp
Try this. In the user password console, give the aspnet account write privilege. If that does'nt work, open the web.config file and set impersonate to true.
Please forgive my ignorance, but where is the user password console? I know I should know this, so don't berate me.
Also, I am using Windows XP, which according to my friend, does not have a security tab on file properties. Mayby that's why I'm having such problems. I know I should kmow how to use my own OS better, but this is how I learn, right? Sure.
-
Mar 27th, 2003, 12:36 PM
#8
hmmm.Havent used XP myself so I don t really know what the deal with that is. I have never heared of password console either.
DevGrp?
-
Mar 27th, 2003, 12:56 PM
#9
Thread Starter
Addicted Member
I figured out how to get the security tab. It's one of the settings in Folder Options -> view. Once I did this, I was able to follow the instructions above and create a file. Yay!
-
Mar 27th, 2003, 01:04 PM
#10
Good. Security options just had to be somewhere.
-
Mar 27th, 2003, 06:16 PM
#11
Frenzied Member
Originally posted by Cander
hmmm.Havent used XP myself so I don t really know what the deal with that is. I have never heared of password console either.
DevGrp?
I was referring to the local users and groups section under the computer managment console in the control panel.
Dont gain the world and lose your soul
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|