Connecting Tech Pros Worldwide Forums | Help | Site Map

Writing to a remote file

Jeff
Guest
 
Posts: n/a
#1: Oct 15 '08
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





Alexey Smirnov
Guest
 
Posts: n/a
#2: Oct 15 '08

re: Writing to a remote file


On Oct 15, 9:33*pm, "Jeff" <some...@somewhere.comwrote:
Quote:
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
Jeff
Guest
 
Posts: n/a
#3: Oct 15 '08

re: Writing to a remote file



"Alexey Smirnov" <alexey.smirnov@gmail.comwrote in message
news:cc0a84e8-3be6-48fc-820e-99acf63a9200@2g2000hsn.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


Alexey Smirnov
Guest
 
Posts: n/a
#4: Oct 16 '08

re: Writing to a remote file


On Oct 15, 11:58*pm, "Jeff" <some...@somewhere.comwrote:
Quote:
"Alexey Smirnov" <alexey.smir...@gmail.comwrote in message
>
news:cc0a84e8-3be6-48fc-820e-99acf63a9200@2g2000hsn.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...

Quote:
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.

Quote:
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

Quote:
>
Thanks again
Jeff
bruce barker
Guest
 
Posts: n/a
#5: Oct 16 '08

re: Writing to a remote file


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:
Quote:
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
>
>
>
>
Jeff
Guest
 
Posts: n/a
#6: Oct 16 '08

re: Writing to a remote file



"bruce barker" <nospam@nospam.comwrote in message
news:OrG2PC0LJHA.2348@TK2MSFTNGP05.phx.gbl...
Quote:
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



Alexey Smirnov
Guest
 
Posts: n/a
#7: Oct 16 '08

re: Writing to a remote file


On Oct 16, 5:59*pm, "Jeff" <some...@somewhere.comwrote:
Quote:
"bruce barker" <nos...@nospam.comwrote in message
>
news:OrG2PC0LJHA.2348@TK2MSFTNGP05.phx.gbl...
>
Quote:
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.
>
Quote:
-- 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
Closed Thread