Allow access to change files

Bucky

Contributor
Joined
Dec 23, 2001
Messages
791
Location
East Coast
Upon trying to save an XmlDocument file, ASP.NET tells me that
access is denied and that I cannot save over a file. This is the error:

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.

Now I'm on Windows XP Pro, and nowhere do I see a place to
change the security options for the file. I also looked in the
ASP.NET service options in admin tools, but no luck.

How do I allow my ASP.NET app access to save the file?
 
Okay, I found something out...
I'm using one XML file, data.xml, to store data in my app.
Each of the pages in the app loads data.xml into an XmlDocument
object (xd.Load(path)). Now when I acces this page directly once,
it updates the file. But every acces after that, the error occurs.

Now there are no errors Loading the file, only for Saving... So I
think the question now is how do I close the XmlDocument after
loading it?

I'm all confused now. :(

[edit]One last thing... If I Load and Save data1.xml (just a copy of
data.xml for testing), it works perfectly... So maybe I need to
Save every time I Load an XmlDocument in the other pages,
even if the XmlDocument isn't modified?[/edit]
 
Last edited:
Whew, I figured it out. Apparently my app can only write over the
file if it was created by that app. So I copied the XML file under
a new name, then deleted the original. Then I temporarily
changed the code to have it read from the copy and write to the
filename I wanted. Then I changed everything back, and it works
like a charm.

Who woulda thunk? :)
 
Back
Top