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

Writing to a remote file

P: n/a
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.x ml' is
denied

Source Error:

Line 35: // Insert data into the XML doc and save
Line 36: myXmlDocument.DocumentElement.InsertBefore(myXmlEl ement,
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


Oct 15 '08 #1
Share this Question
Share on Google+
6 Replies


P: n/a
On Oct 15, 9:33*pm, "Jeff" <some...@somewhere.comwrote:
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.x ml' is
denied

Source Error:

Line 35: * * * * // Insert data into the XML doc and save
Line 36: * * * * myXmlDocument.DocumentElement.InsertBefore(myXmlEl ement,
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
Oct 15 '08 #2

P: n/a

"Alexey Smirnov" <al************@gmail.comwrote in message
news:cc**********************************@2g2000hs n.googlegroups.com...
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
Oct 15 '08 #3

P: n/a
On Oct 15, 11:58*pm, "Jeff" <some...@somewhere.comwrote:
"Alexey Smirnov" <alexey.smir...@gmail.comwrote in message

news:cc**********************************@2g2000hs n.googlegroups.com...
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&r...APTCHA+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

>
Thanks again
Jeff
Oct 15 '08 #4

P: n/a
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)

Jeff wrote:
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.x ml' is
denied

Source Error:

Line 35: // Insert data into the XML doc and save
Line 36: myXmlDocument.DocumentElement.InsertBefore(myXmlEl ement,
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

Oct 16 '08 #5

P: n/a

"bruce barker" <no****@nospam.comwrote in message
news:Or**************@TK2MSFTNGP05.phx.gbl...
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

Oct 16 '08 #6

P: n/a
On Oct 16, 5:59*pm, "Jeff" <some...@somewhere.comwrote:
"bruce barker" <nos...@nospam.comwrote in message

news:Or**************@TK2MSFTNGP05.phx.gbl...
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 folderbe
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
http://petesbloggerama.blogspot.com/...plication.html
Oct 16 '08 #7

This discussion thread is closed

Replies have been disabled for this discussion.