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