By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,457 Members | 1,301 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,457 IT Pros & Developers. It's quick & easy.

Trying to edit XML, error xml file is denied, how to i get access

P: n/a
So i have an xml file, i'm grabbing it via dataset, then placing the
data into a datagrid. everythings all good, but i'd like to edit the
data. the coding grabs whats in the edit textboxes, and should throw it
back to the xml file, but i get an error

"System.UnauthorizedAccessException: Access to the path
"c:\inetpub\wwwroot\work\xmlfile1.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 <identity
impersonate="true"/>, 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 "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."

please help, how can i permit access to edit the file, i've tried
going into the files properties and making sure its not read only, but
still, nothing.

Jan 3 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
<jo**********@gmail.com> wrote in message news:11*********************@f14g2000cwb.googlegro ups.com...
"System.UnauthorizedAccessException: Access to the path
"c:\inetpub\wwwroot\work\xmlfile1.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. : : 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 appropriate user or group. Highlight the ASP.NET account,
and check the boxes for the desired access."

please help, how can i permit access to edit the file


The exception message explains how to grant write access to the file,
if you read the last paragraph more closely. The issue has nothing to
do with the read-only flag in the file system, it relates to Windows'
security privileges on that folder and file. You must configure the
folder to authorize ASP.NET so it can create files within the folder
(if this is a new file), and for the files you want ASP.NET to change
you must authorize ASP.NET to write them.

The "quick and dirty" solution is usually to add the ASP.NET user
(again, see the error message for what user name that is by default
based on the version of .NET and IIS you have installed) and
check the "Modify" checkbox on the folder (inherited by all
it's files and subfolders).

This is overkill, but effective enough for running code for learning
purposes. In a real world application you would define a specific
security policy involving a grant of access to the smallest set of
resources through a least privileges user account created just
for this individual application.

Please note that if you're running Win XP and you have the "simplified
sharing" feature turned on (the default regrettably being, "yes," although
it's right up there with the "hide system files" and "hide file extensions"
features [for greater user-friendliness] that all developers, IMHO, should
turn off immediately), then you will not see a Security tab when you
view a file's properties. See this Microsoft knowledge base article
for information on turning off "simplified sharing,"

http://support.microsoft.com/kb/307874/en-us
Derek Harmon
Jan 3 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.