Results 1 to 3 of 3

Thread: save xml file

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Dec 2002
    Location
    London
    Posts
    678

    save xml file

    I am still unable to save data into my xml file.
    The error is:
    ----------------------------------------
    Access to the path "c:\inetpub\wwwroot\Farshad\ASP.NET\DSL\ctcUsers.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 "c:\inetpub\wwwroot\Farshad\ASP.NET\DSL\ctcUsers.xml" is denied.

    The ASP.NET process is not authorized to access the requested resource. For security reasons the default ASP.NET process identity is '{machinename}\ASPNET', which has limited privileges. Consider granting access rights to the resource to the ASP.NET process identity.

    To grant ASP.NET write access to a file, right-click the file in Explorer, choose "Properties" and select the Security tab. Click "Add" to add the "{machinename}\ASPNET" user. Highlight the ASP.NET account, and check the Write box in the Allow column.
    ----------------------------------------

    This is the code that I am using to save into the xml file.
    Please remember that this procedure works fine if I use a vb.net application but it gives the above error when in ASP.NET

    p.s. The ctcUsers.xml is NOT readonly in explorer

    Private Sub SaveDataToXML()
    Dim strPath As String = Server.MapPath(Request.ApplicationPath)
    Dim doc As XmlDocument = New XmlDocument()

    doc.Load(strPath & "\ctcUsers.xml")
    Dim rootNode As XmlElement = doc.DocumentElement

    Dim NewUser As XmlElement = doc.CreateElement("User")

    Dim NewFirstName As XmlElement = doc.CreateElement("firstname")
    NewFirstName.InnerText = txtFirstName.Text
    NewUser.AppendChild(NewFirstName)

    Dim NewSurname As XmlElement = doc.CreateElement("surname")
    NewSurname.InnerText = txtSurname.Text
    NewUser.AppendChild(NewSurname)

    Dim NewAge As XmlElement = doc.CreateElement("age")
    NewAge.InnerText = txtAge.Text
    NewUser.AppendChild(NewAge)

    Dim NewPhone As XmlElement = doc.CreateElement("phone")
    NewPhone.InnerText = txtPhone.Text
    NewUser.AppendChild(NewPhone)

    Dim NewEmail As XmlElement = doc.CreateElement("email")
    NewEmail.InnerText = txtEmail.Text
    NewUser.AppendChild(NewEmail)

    rootNode.AppendChild(NewUser)

    'Here is when the error occurs.......................
    doc.Save(strPath & "\ctcUsers.xml")
    .....................................................

    End Sub

  2. #2
    PowerPoster hellswraith's Avatar
    Join Date
    Jul 2002
    Location
    Washington St.
    Posts
    2,464
    Did you do this?

    The ASP.NET process is not authorized to access the requested resource. For security reasons the default ASP.NET process identity is '{machinename}\ASPNET', which has limited privileges. Consider granting access rights to the resource to the ASP.NET process identity.

    To grant ASP.NET write access to a file, right-click the file in Explorer, choose "Properties" and select the Security tab. Click "Add" to add the "{machinename}\ASPNET" user. Highlight the ASP.NET account, and check the Write box in the Allow column.

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Dec 2002
    Location
    London
    Posts
    678
    BUT, when I right click on the .xml file in explorer it only shows the general tab. I don't know where else to check to set the permissions, etc.
    Thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width