App_Data permissions lock(_path) error...STILL!!! -fixed

Topics: Developer Forum, User Forum
Feb 7, 2009 at 4:54 PM
Ok.  I feel like i have read every post on this site regarding this error message, and I think I'm going to pull my hair out if I don't resolve this today.  I have spent way too much time trying to get the permissions correct for my site.  

 

Server Error in '/' Application.

Access to the path 'D:\clnts\www.crowncomputers.biz\App_Data\Users.config' 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:\clnts\www.crowncomputers.biz\App_Data\Users.config' 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 511:            lock (_path)
Line 512:            {
Line 513: _users.WriteXml(_path, XmlWriteMode.WriteSchema);Line 514:            }
Line 515:        }

Source File: d:\clnts\www.crowncomputers.biz\App_Code\Providers\CustomXmlMembershipProvider.cs    Line: 513

Stack Trace:

[UnauthorizedAccessException: Access to the path 'D:\clnts\www.crowncomputers.biz\App_Data\Users.config' 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.Data.DataTable.WriteXml(String fileName, XmlWriteMode mode, Boolean writeHierarchy) +84
   System.Data.DataTable.WriteXml(String fileName, XmlWriteMode mode) +10
   MyWebPagesStarterKit.Providers.CustomXmlMembershipProvider.save() in d:\clnts\www.crowncomputers.biz\App_Code\Providers\CustomXmlMembershipProvider.cs:513
   MyWebPagesStarterKit.Providers.CustomXmlMembershipProvider.ValidateUser(String username, String password) in d:\clnts\www.crowncomputers.biz\App_Code\Providers\CustomXmlMembershipProvider.cs:474
   System.Web.UI.WebControls.Login.AuthenticateUsingMembershipProvider(AuthenticateEventArgs e) +60
   System.Web.UI.WebControls.Login.OnAuthenticate(AuthenticateEventArgs e) +119
   System.Web.UI.WebControls.Login.AttemptLogin() +115
   System.Web.UI.WebControls.Login.OnBubbleEvent(Object source, EventArgs e) +101
   System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +37
   System.Web.UI.WebControls.Button.OnCommand(CommandEventArgs e) +118
   System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +166
   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.3072


My hosting provider is infosaic and it's a shared hosting service.  The hosting provider does not allow the user to set read, write, AND, execute permission to one directory.  I set the App_data directory to write permissions in order to write to the users.config file.  Am I correct?  Has anybody else used this hosting service and what is your impression of the service?  I have a 30 day guarantee on the hosting service.

Thanks for any help.

Katie
<!-- [UnauthorizedAccessException]: Access to the path 'D:\clnts\www.crowncomputers.biz\App_Data\Users.config' is denied. at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) at 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) at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share) at System.Xml.XmlTextWriter..ctor(String filename, Encoding encoding) at System.Data.DataTable.WriteXml(String fileName, XmlWriteMode mode, Boolean writeHierarchy) at System.Data.DataTable.WriteXml(String fileName, XmlWriteMode mode) at MyWebPagesStarterKit.Providers.CustomXmlMembershipProvider.save() in d:\clnts\www.crowncomputers.biz\App_Code\Providers\CustomXmlMembershipProvider.cs:line 513 at MyWebPagesStarterKit.Providers.CustomXmlMembershipProvider.ValidateUser(String username, String password) in d:\clnts\www.crowncomputers.biz\App_Code\Providers\CustomXmlMembershipProvider.cs:line 474 at System.Web.UI.WebControls.Login.AuthenticateUsingMembershipProvider(AuthenticateEventArgs e) at System.Web.UI.WebControls.Login.OnAuthenticate(AuthenticateEventArgs e) at System.Web.UI.WebControls.Login.AttemptLogin() at System.Web.UI.WebControls.Login.OnBubbleEvent(Object source, EventArgs e) at System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) at System.Web.UI.WebControls.Button.OnCommand(CommandEventArgs e) at System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) at System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) [HttpUnhandledException]: Exception of type 'System.Web.HttpUnhandledException' was thrown. at System.Web.UI.Page.HandleError(Exception e) at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) at System.Web.UI.Page.ProcessRequest() at System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context) at System.Web.UI.Page.ProcessRequest(HttpContext context) at ASP.login_aspx.ProcessRequest(HttpContext context) in c:\Windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\d82d567a\82f35de9\App_Web_a2u8lrv8.4.cs:line 0 at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) --><!-- This error page might contain sensitive information because ASP.NET is configured to show verbose error messages using <customErrors mode="Off"/>. Consider using <customErrors mode="On"/> or <customErrors mode="RemoteOnly"/> in production environments.-->
Feb 7, 2009 at 11:12 PM
I fixed it by e-mailing the hosting company.  They tested and said the only way to fix it was to rename the file.  Anybody else have this issue?  I have to rename every page that was created and is referenced.
Coordinator
Feb 8, 2009 at 9:54 AM
Try to change folder name from App_Data to another one - for example AppData, then it's not ASP.NET folder but regular folder. How to change? Just "Replace All" in Visual Studio from "App_Data" to "AppData"
Feb 8, 2009 at 8:07 PM

Thanks for the suggestion. I am in the process of changing all the folders like that to see if fixes my problem. The only issue that I can possibly predict is even if I give the directory “write” permissions, will the “read/execute” work by default? I’m setting up a virtual environment with my own IIS to see if works. Please let me know if you have any suggestions on hosting the site in a virtual environment.

Best regards,

Katie

Feb 9, 2009 at 1:13 AM

I changed the App_Data to AppData and started to get errors from the App_Code folder. I thought the same issue was happening, so I changed the App_Code folder to AppCode. I did the replace all in the entire solution for all references to these folders as well. Now the global.asax file is not recognizing the MyWebPagesStarterKit class. I don’t want to change any more code until I find out if there something else I should have done. I don’t know the proper vocabulary to search the necessary file structure nor the entry point to place the breakpoint for debugging. If anybody can help or has had the same issue, that would be helpful.

Thanks.

Best regards,

Katie

Feb 18, 2009 at 5:43 PM
Hi Katie
If you read the errormessage above you can see the following .
Just follow the instructions and it works.
1.) To grant ASP.NET access to a file, right-click the file "Users.config" in the file - Explorer
2) choose "Properties"
3) and select the Security tab.
4)Click "Add" to add the appropriate user or group.
Missing info in errormessage.Choose advanced and search for the ASPNET user on the machine which is hosting your website
5) Highlight the ASP.NET account, and check the boxes for the desired access. (give the user all access rights)

This means that the ASPNET user (on  infosaic your hosting service) should have read/write access to the Users.config file.

Hope this will work for you
Good luck
regards Berndt

Feb 18, 2009 at 8:35 PM

Thanks I have fixed it. I do appreciate the step by step approach. I’m sure somebody else will make good use out of it.

Best regards,

Katie Schmidt

Katie Schmidt's VisualCV

http://www.brightfuse.com/katie-schmidt-2