PDA

View Full Version : Writing to xml file, access denied


jpopesku
08-04-2004, 07:17 AM
Hey all. I'm attempting to create a (or rather tweak someone else's) guestbook that uses xml. I have everything working nicely except for when I try to post a new entry. Reading from the file is not a problem, but writing is. The error is:
[quote]
Accesstothepath"E:\web\teamendoca0\htdocs\Community\guestbook.xml"isdenied.
Description:Anunhandledexceptionoccurredduringthee xecutionofthecurrentwebrequest.Pleasereviewthestac ktraceformoreinformationabouttheerrorandwhereitori ginatedinthecode.

ExceptionDetails:System.UnauthorizedAccessExceptio n:Accesstothepath"E:\web\teamendoca0\htdocs\Community\guestbook.xml"isdenied.

ASP.NETisnotauthorizedtoaccesstherequestedresource .ConsidergrantingaccessrightstotheresourcetotheASP .NETrequestidentity.ASP.NEThasabaseprocessidentity (typically{MACHINE}\ASPNETonIIS5orNetworkServiceon IIS6)thatisusediftheapplicationisnotimpersonating. Iftheapplicationisimpersonatingvia<identityimpersonate="true"/>,theidentitywillbetheanonymoususer(typicallyIUSR_M ACHINENAME)ortheauthenticatedrequestuser.

TograntASP.NETwriteaccesstoafile,right-clickthefileinExplorer,choose"Properties"andselecttheSecuritytab.Click"Add"toaddtheappropriateuserorgroup.HighlighttheASP.NET account,andchecktheboxesforthedesiredaccess.

SourceError:


Line36://InsertthenewelementintotheXMLtreeandsave
Line37:myXmlDocument.DocumentElement.InsertBefore( myXmlElement,myXmlNode);
Line38:myXmlDocument.Save(Server.MapPath("guestbook.xml"));</fontid="red">
Line39:
Line40://Re-binddatasincethedatahaschanged.
</CODE>

I currently have the .xml file stored in the root directory. Should I be keeping it somewhere else that allows write-access to the file?

Thanks for your help.
JP

infinitedes
08-04-2004, 08:54 AM
I believe if you are using www.discountasp.com to host
your site where you are writing this script it will be
necessary to have the xml file stored in one of your
directories. Since you are writing server-side scripts
they only have access to files on your server; in this
case the files hosted by discountasp. To access files
from another source you need a client-side component.

[8]

Owen

bruce
08-05-2004, 03:47 AM
Create a support ticket, we can double check permission for you.

Permission can get screw up if you have frontpage extension enabled.

[b]quote:Originally posted by infinitedes

I believe if you are using www.discountasp.com to host
your site where you are writing this script it will be
necessary to have the xml file stored in one of your
directories. Since you are writing server-side scripts
they only have access to files on your server; in this
case the files hosted by discountasp. To access files
from another source you need a client-side component.

[8]

Owen
</blockquote id="quote"></font id="quote">

jpopesku
08-05-2004, 08:19 AM
Owen: thanks for the reply, but the file is on the server (hence the call to the Server.MapPath() method). The file seems to have read-only access in the directory that it's in on the DASP server (I can view the file's contents via ASP.NET) but doesn't seem to have write-access (I can't change the contents via ASP.NET).
Is there I folder on the server that I should move the file to in order to have write access to it??

Thanks,
JP

[b]quote:Originally posted by infinitedes

I believe if you are using www.discountasp.com to host
your site where you are writing this script it will be
necessary to have the xml file stored in one of your
directories. Since you are writing server-side scripts
they only have access to files on your server; in this
case the files hosted by discountasp. To access files
from another source you need a client-side component.

[8]

Owen
</blockquote id="quote"></font id="quote">

diltonm
08-05-2004, 09:08 AM
I think you need a forward slash in front of guesbook.xml or else the path will map to DASP root on the server instead of your application directory + "\Community".

jpopesku
08-09-2004, 06:47 AM
In case anyone else is following this thread, contacting support with my problem fixed it. [8D]


[b]quote:Originally posted by bruce

Create a support ticket, we can double check permission for you.

Permission can get screw up if you have frontpage extension enabled.

[b]quote:Originally posted by infinitedes

I believe if you are using www.discountasp.com to host
your site where you are writing this script it will be
necessary to have the xml file stored in one of your
directories. Since you are writing server-side scripts
they only have access to files on your server; in this
case the files hosted by discountasp. To access files
from another source you need a client-side component.

[8]

Owen
</blockquote id="quote"></font id="quote">
</blockquote id="quote"></font id="quote">