error on the server

Last post 07-07-2009 5:32 PM by papabear. 12 replies.

Sort Posts:

  • error on the server

    07-04-2009, 2:21 PM

    Hello,

    I developed a website (in asp.net) with has XML database and It works fine on my local machine but when I deployed it on the server I am getting below error message (part of error message which tells me what to do to fix it).

    To grant ASP.NET access to a file, right-click the file in Explorer, choose "Properties" and select the Security tab. Click "Add" to add the appropriate user or group. Highlight the ASP.NET account, and check the boxes for the desired access.

    I followed the below instructions and tried to grant ASP.NET access to this xml file.

    Right-click the xml file->properties->security tab->edit->add->advance->find now->ASPNET->ok and checked the boxes for permissions (read, write, modify, full control).

    But still getting the same error!!

    Can anyone please tell me what I am doing wrong? Is there a way to fix this?

    The full error message is below:

     

    Server Error in '/' Application.

    Access to the path 'd:\hosting\coolix\guestbook.xml' is denied.

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.UnauthorizedAccessException: Access to the path 'd:\hosting\coolix\guestbook.xml' is denied.

    ASP.NET is not authorized to access the requested resource. Consider granting access rights to the resource to the ASP.NET request identity. ASP.NET has a base process identity (typically {MACHINE}\ASPNET on IIS 5 or Network Service on IIS 6) that is used if the application is not impersonating. If the application is impersonating via <identity impersonate="true"/>, the identity will be the anonymous user (typically IUSR_MACHINENAME) or the authenticated request user.

    To grant ASP.NET access to a file, right-click the file in Explorer, choose "Properties" and select the Security tab. Click "Add" to add the appropriate user or group. Highlight the ASP.NET account, and check the boxes for the desired access.

    Source Error:

    Line 39:         addTextElement(xmldoc, elem, "date", strDate);
    Line 40: 
    Line 41:         xmldoc.Save(Server.MapPath("guestbook.xml"));
    Line 42:         Label1.Text = "Thank you! Your comment has been saved and will be visible after owner approvel.";
    Line 43:         //.Redirect("view-guestbook.aspx");

    Source File: d:\hosting\coolix\guest-book.aspx.cs    Line: 41

    Stack Trace:

    [UnauthorizedAccessException: Access to the path 'd:\hosting\coolix\guestbook.xml' is denied.]
       System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) +7712175
       System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy) +1162
       System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share) +66
       System.Xml.XmlTextWriter..ctor(String filename, Encoding encoding) +37
       System.Xml.XmlDocument.Save(String filename) +77
       Default3.submit_Click(Object sender, EventArgs e) in d:\hosting\coolix\guest-book.aspx.cs:41
       System.Web.UI.WebControls.Button.OnClick(EventArgs e) +111
       System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +110
       System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
       System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
       System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565
    


    Version Information: Microsoft .NET Framework Version:2.0.50727.3053; ASP.NET Version:2.0.50727.3053

  • Re: error on the server

    07-04-2009, 4:12 PM

    Hello,

    If you read carefully you will see that there is a difference between Windows XP and Server 2003, so you should give access not to ASP.NET machine account, but to Network machine account.

    Regards

  • Re: error on the server

    07-04-2009, 5:06 PM

     Thanks for your reply. These are the accounts which i gave access to:

    ASP.NET Machine Account (My machine name\ASPNET), NETWORK, NETWORK SERVICE, SYSTEM, IUSR, REMOTE INTERACTIVE LOGON, Authenticated Users, Everyone, IS_IUSRS, ANONYMOUS LOGON.

    still not working!! getting same error message

    I am giving access to the right account?

    You asked to try Network machine account....there are two accounts with network in it: NETWORK and NETWORK SERVICE....as you can see i gave access to both accounts but still not working

  • Re: error on the server

    07-05-2009, 2:55 PM
    • Contributor
      6,366 point Contributor
    • Lee Dumond
    • Member since 11-03-2004, 2:51 PM
    • Decatur, IL USA
    • Posts 1,168

     Are you sure you gave access to the right directory? And did you give Read/Write/Modify access, or just Read?

  • Re: error on the server

    07-05-2009, 3:32 PM

     I am not sure What do you mean by right directory because the error message says that "grant access to ASP.NET". so i followed the steps which were given in the error message and found some groups or users which i can give access to. i have listed them in my previous post. and yes, i have giving full access i.e. read/write and modify access.

    Thanks

  • Re: error on the server

    07-05-2009, 3:47 PM
    • Contributor
      6,366 point Contributor
    • Lee Dumond
    • Member since 11-03-2004, 2:51 PM
    • Decatur, IL USA
    • Posts 1,168

     Sorry, I mean access to the right path. Which in this case would apparently be 'd:\hosting\coolix\guestbook.xml'.

  • Re: error on the server

    07-05-2009, 4:06 PM

     I dont know why but error message says 'd:' drive. my domain name on the server is 'coolix' and guestbook.xml is the xml file which is suppose to be my database. and i think 'd:\hosting' is the drive on the server.

    so i am not sure about the path is correct or not. I just uploaded my project (i.e. website with all the webpages) on to the server and tried to access the website on the net. when i tried to use the guestbook feature of my site its giving me above error message.

    I dont know what else to do!! Cry

    Thanks

  • Re: error on the server

    07-05-2009, 9:54 PM
    • Contributor
      6,366 point Contributor
    • Lee Dumond
    • Member since 11-03-2004, 2:51 PM
    • Decatur, IL USA
    • Posts 1,168

     It sounds like what you did was to grant access to the path on your local machine. What I was aking is if you granted proper access to the correct path on the server machine. That would probably be why you're getting this error.

  • Re: error on the server

    07-05-2009, 11:21 PM

     the options present in xml file (under its properties) for 'Select User or Group' are:

    ANONYMOUS LOGON;                  LOCAL SERVICE;

    Authenticated Users;                     NETWORK;

    BATCH;                                             NETWORK SERVICE;

    CREATOR GROUP;                          OWNER RIGHTS;

    CREATOR OWNER;                         REMOTE INTERACTIVE LOGON;

    DIALUP;                                            SERVICE;

    Everyone;                                         SYSTEM;

    INTERACTIVE;                                TERMINAL SERVER USER

    IUSR;

    can you tell me which one of the above options relates to the server machine.

    Thanks.

  • Re: error on the server

    07-06-2009, 5:43 PM
    • Contributor
      6,366 point Contributor
    • Lee Dumond
    • Member since 11-03-2004, 2:51 PM
    • Decatur, IL USA
    • Posts 1,168

     Do you know what OS (or version of IIS) is running on your server?

  • Re: error on the server

    07-06-2009, 6:54 PM

     IIS 6.0

  • Re: error on the server

    07-07-2009, 5:23 PM
    • Contributor
      6,366 point Contributor
    • Lee Dumond
    • Member since 11-03-2004, 2:51 PM
    • Decatur, IL USA
    • Posts 1,168

     Well then, it would be NETWORK SERVICE. But again, you have to do this ON the actual server, not just on your local machine.

  • Re: error on the server

    07-07-2009, 5:32 PM
    Answer
    • Contributor
      5,138 point Contributor
    • papabear
    • Member since 08-08-2005, 11:49 AM
    • Posts 851

    http://msdn.microsoft.com/en-us/library/ms998320.aspx on how to setup the Network Service acct...

    ;)

    give me suggestions for what to blog... http://www.myfriedmind.com/techblog -> thx

    Mark as "Answered" if this solves that wee old problem...
Page 1 of 1 (13 items)