Writing to a remote file

Discussion in 'ASP .Net' started by Jeff, Oct 15, 2008.

  1. Jeff

    Jeff 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
     
    Jeff, Oct 15, 2008
    #1
    1. Advertisements

  2. 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
     
    Alexey Smirnov, Oct 15, 2008
    #2
    1. Advertisements

  3. Jeff

    Jeff 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 - 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
     
    Jeff, Oct 15, 2008
    #3
  4. If I were you I would do this option. It would be easy to control
    access rights...

    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.

    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
     
    Alexey Smirnov, Oct 16, 2008
    #4
  5. Jeff

    bruce barker Guest

    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)
     
    bruce barker, Oct 16, 2008
    #5
  6. Jeff

    Jeff Guest

    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
     
    Jeff, Oct 16, 2008
    #6
  7. Alexey Smirnov, Oct 16, 2008
    #7
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.