Writing to a remote file

J

Jeff

Hi

I'm fairly new to ASP.NET and am running Visual Studio 2005. I'm having a
problem implementing a guestbook page - wondered if someone could shed some
light on where I'm going wrong?

The application runs ok on my local server, but when I try running it on my
remote web hosting service I seem to have problems saving the xml file.
Here's a summary of the message I receive when I hit my submit button and
try to write back into the guestbook:

Access to the path 'C:\Inetpub\vhosts\**********\httpdocs\guestbook.xml' is
denied

Source Error:

Line 35: // Insert data into the XML doc and save
Line 36: myXmlDocument.DocumentElement.InsertBefore(myXmlElement,
myXmlNode);
Line 37: myXmlDocument.Save(Server.MapPath("~/guestbook.xml"));
Line 38:
Line 39: // Re-bind data since the doc has been added to


It reads the guestbokk ok, but it looks almost like the file is read-only -
although I'm sure I didn't set it as such.
Is anyone familiar enough with the Parallels hosting service to advise me
how to ensure that the file attributes are correctly set?
Can I test the attributes from a browser?

Thanks for any help

Jeff
 
G

Guest

Hi

I'm fairly new to ASP.NET and am running Visual Studio 2005. I'm having a
problem implementing a guestbook page - wondered if someone could shed some
light on where I'm going wrong?

The application runs ok on my local server, but when I try running it on my
remote web hosting service I seem to have problems saving the xml file.
Here's a summary of the message I receive when I hit my submit button and
try to write back into the guestbook:

Access to the path 'C:\Inetpub\vhosts\**********\httpdocs\guestbook.xml' is
denied

Source Error:

Line 35:         // Insert data into the XML doc and save
Line 36:         myXmlDocument.DocumentElement.InsertBefore(myXmlElement,
myXmlNode);
Line 37:         myXmlDocument.Save(Server.MapPath("~/guestbook.xml"));
Line 38:
Line 39:         // Re-bind data since the doc has been added to

It reads the guestbokk ok, but it looks almost like the file is read-only -
although I'm sure I didn't set it as such.
Is anyone familiar enough with the Parallels hosting service to advise me
how to ensure that the file attributes are correctly set?
Can I test the attributes from a browser?

Thanks for any help

Jeff

Hi Jeff

this message means that the user account used for ASP.NET has no
rights to write in a files in that directory. The IIS Process Model on
IIS 6+ uses the NETWORK SERVICE account, and IIS 5 uses the ASPNET
account. You need to go to the control panel of your hosting service
and give write access for the required directory.

Hope this helps
 
J

Jeff

Hi Jeff

this message means that the user account used for ASP.NET has no
rights to write in a files in that directory. The IIS Process Model on
IIS 6+ uses the NETWORK SERVICE account, and IIS 5 uses the ASPNET
account. You need to go to the control panel of your hosting service
and give write access for the required directory.

Hope this helps

Thanks Alexey

So, is it better to move this file to a sub-directory (say httpdocs/public)
and give write access to that rather than risk having other files within
httpdocs overwritten - or can I set permissions at the file level as well as
the directory level?

And is there any simple way to stop a mallicious user from filling up my
web-space with junk?

Thanks again
Jeff
 
G

Guest

Hi Jeff

this message means that the user account used for ASP.NET has no
rights to write in a files in that directory. The IIS Process Model on
IIS 6+ uses the NETWORK SERVICE account, and IIS 5 uses the ASPNET
account. You need to go to the control panel of your hosting service
and give write access for the required directory.

Hope this helps

Thanks Alexey

So, is it better to move this file to a sub-directory (say httpdocs/public)
and give write access to that rather than risk having other files within
httpdocs overwritten -

If I were you I would do this option. It would be easy to control
access rights...

or can I set permissions at the file level as well as
the directory level?

Yes, you can do this. You might need to uncheck the default "inherit
from parent" flag in the Plesk and give all necessary attributes to a
single file.

And is there any simple way to stop a mallicious user from filling up my
web-space with junk?

Well the easiest way I think is CAPTCHA
http://www.google.com/search?hl=en&rls=com.microsoft:en-US&q=CAPTCHA+asp.net

Another way is to moderate the whole, or moderate all comments with
"www." and "http://"

Plus don't forget to strip off html tags
 
B

bruce barker

you should be writing files to the app_data folder as writing to this
folder will not trigger a application recycle. also its protected from
users being able to download files directly. when you create the folder
be sure to give the appdomain account access.

-- bruce (sqlwork.com)
 
J

Jeff

bruce barker said:
you should be writing files to the app_data folder as writing to this
folder will not trigger a application recycle. also its protected from
users being able to download files directly. when you create the folder be
sure to give the appdomain account access.

-- bruce (sqlwork.com)

Thanks bruce.

Can I just check I understand you correctly here?
Are you saying that changing a file in any directory other than App_Data may
trigger a recylce?
Does that mean a rebuild of the app's dll's ?
Just wanted to check.

Thanks
Jeff
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top