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