Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Access Denied error [modified]

Access Denied error [modified]

Scheduled Pinned Locked Moved ASP.NET
asp-netsysadmincsharpwindows-adminhosting
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    maizhiming
    wrote on last edited by
    #1

    I am relatively new to ASP.NET and have just uploaded my first page. I have a "Save" function that writes information from a control to an XML file. Whenever I try to run this function I get this error from ASP.NET: Server Error in '/' Application. -------------------------------------------------------------------------------- Access to the path 'c:\windows\system32\inetsrv\favorites.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:\windows\system32\inetsrv\favorites.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 , 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. -------------------------------------------------------------------------------------- I'm not sure how to change the access rights because I am using a web hosting service. It works fine on my local machine. What should I do from here?

    M S 2 Replies Last reply
    0
    • M maizhiming

      I am relatively new to ASP.NET and have just uploaded my first page. I have a "Save" function that writes information from a control to an XML file. Whenever I try to run this function I get this error from ASP.NET: Server Error in '/' Application. -------------------------------------------------------------------------------- Access to the path 'c:\windows\system32\inetsrv\favorites.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:\windows\system32\inetsrv\favorites.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 , 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. -------------------------------------------------------------------------------------- I'm not sure how to change the access rights because I am using a web hosting service. It works fine on my local machine. What should I do from here?

      M Offline
      M Offline
      minhpc_bk
      wrote on last edited by
      #2

      You need to contact the admin if you don't have the control to ensure that you are given a place where your application has the write permission. For more information, see ASP.NET process identity[^]

      1 Reply Last reply
      0
      • M maizhiming

        I am relatively new to ASP.NET and have just uploaded my first page. I have a "Save" function that writes information from a control to an XML file. Whenever I try to run this function I get this error from ASP.NET: Server Error in '/' Application. -------------------------------------------------------------------------------- Access to the path 'c:\windows\system32\inetsrv\favorites.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:\windows\system32\inetsrv\favorites.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 , 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. -------------------------------------------------------------------------------------- I'm not sure how to change the access rights because I am using a web hosting service. It works fine on my local machine. What should I do from here?

        S Offline
        S Offline
        Sushant Duggal
        wrote on last edited by
        #3

        HI, Can you write the code here that you are using. Thanks, Sushant Duggal.

        M 1 Reply Last reply
        0
        • S Sushant Duggal

          HI, Can you write the code here that you are using. Thanks, Sushant Duggal.

          M Offline
          M Offline
          maizhiming
          wrote on last edited by
          #4

          Here is the code that I am using. I am referencing the file in the last sub-routine "Save_Click".

          Sub SaveNodes(ByVal nodesCollection As TreeNodeCollection, ByVal textWriter As System.Xml.XmlTextWriter)
          Dim link_node As TreeNode
          For Each link_node In nodesCollection
          If link_node.ChildNodes.Count Then
          textWriter.WriteStartElement("Folder")
          textWriter.WriteAttributeString("Name", link_node.Text)
          textWriter.WriteRaw(vbCrLf)
          Else
          textWriter.WriteStartElement("Link")
          textWriter.WriteAttributeString("Name", link_node.Text)
          textWriter.WriteAttributeString("Location", link_node.NavigateUrl)
          End If

               If link\_node.ChildNodes.Count > 0 Then
                  SaveNodes(link\_node.ChildNodes, textWriter)
               End If
               textWriter.WriteEndElement()
               textWriter.WriteRaw(vbCrLf)
            Next
          

          End Sub

          Sub SaveTreeViewData(ByVal treeView As TreeView, ByVal path As String)
          'Create a serializer and file to save TreeViewData
          Dim TextWriter As New System.Xml.XmlTextWriter(path, System.Text.Encoding.UTF8)

            TextWriter.WriteStartDocument()
            TextWriter.WriteRaw(vbCrLf)
          
            SaveNodes(treeView.Nodes, TextWriter)
          
            TextWriter.Close()
          

          End Sub

          Protected Sub Save_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Save.Click
          SaveTreeViewData(Link_Tree, "favorites.xml")
          End Sub

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups