UnauthorizedAccessException

Topics: Developer Forum, User Forum
Feb 12, 2009 at 6:33 PM

I just hosted this site on 1and1.com, but I don't know what else should I have to do to fix  the following unauthorized access exception.

I really appreciate any help.



Access to the path 'E:\kunden\homepages\9\d268345851\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 'E:\kunden\homepages\9\d268345851\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: e:\kunden\homepages\9\d268345851\App_Code\Providers\CustomXmlMembershipProvider.cs    Line: 513

Stack Trace:

[UnauthorizedAccessException: Access to the path 'E:\kunden\homepages\9\d268345851\App_Data\Users.config' is denied.]
   System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) +651
   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) +1038
   System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share) +114
   System.Xml.XmlTextWriter..ctor(String filename, Encoding encoding) +38
   System.Data.DataTable.WriteXml(String fileName, XmlWriteMode mode, Boolean writeHierarchy) +76
   System.Data.DataTable.WriteXml(String fileName, XmlWriteMode mode) +10
   MyWebPagesStarterKit.Providers.CustomXmlMembershipProvider.save() in e:\kunden\homepages\9\d268345851\App_Code\Providers\CustomXmlMembershipProvider.cs:513
   MyWebPagesStarterKit.Providers.CustomXmlMembershipProvider.ValidateUser(String username, String password) in e:\kunden\homepages\9\d268345851\App_Code\Providers\CustomXmlMembershipProvider.cs:474
   System.Web.UI.WebControls.Login.OnAuthenticate(AuthenticateEventArgs e) +160
   System.Web.UI.WebControls.Login.AttemptLogin() +105
   System.Web.UI.WebControls.Login.OnBubbleEvent(Object source, EventArgs e) +99
   System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +35
   System.Web.UI.WebControls.Button.OnCommand(CommandEventArgs e) +115
   System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +163
   System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11
   System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1746


Version Information: Microsoft .NET Framework Version:2.0.50727.1433; ASP.NET Version:2.0.50727.1433
Feb 13, 2009 at 12:32 PM

I had the same problems when I created the whole website and all it's content on my local machine and then uploaded to the hosting company.  If the permissions on the App_Data are not causing the problem, then try renaming the file to Users1.config.  Once I did this, it got past this file error.  Any page is you created locally will have a GUID page id that is referenced, so you are likely to have the same problem if you try to edit any of the pages live on the web by using the FCKEditor.

Feel free to ask me questions, I spent a lot of time on this and wouldn't want anyone else to waste time.

Also, 1and1.com support is very good (although sometimes you can't understand them), so you may want to make sure that your files are set up correctly.

Hope this helps.
katie

Mar 9, 2009 at 6:10 PM
Probably has to do with the App_Data folder permissions

Using 1and1.com hosting is probably Plesk control panel

Setting file/folder permissions from Plesk control panel for Windows
Article ID:478

For users on Plesk for Windows:

  1. Login to Plesk control panel using the URL  https://YourDomain.com:8443
  2. Click on the domain name for which you want to change the permission.
  3. Click on the File Manager icon, You will see a few folders like private,httpdocs,httpsdocs These are base folders and if you need to give permissions to any of these as a whole, you need to submit a support request.
  4. Click on the httpdocs folder.You will mostly need to set permission for the files/folders inside the httpdocs folder, which is the root folder of your domain
  5. Decide the file/folder you want to set permission,and towards the right side of that you will see a 'lock' symbol  ,Click on that
  6. You'll see a list of Group or user names (like those listed in the follow bullets) and towards the right side of that you'll see permissions for that user:
    • Administrators
    • SYSTEM
    • Plesk Domain User (number)
    • FPSE_number
    • Plesk IIS User (IUSR_number)
    • Plesk IIS WP User (IWPD_number(number))
  7. This is where you need to set permissions.
    • For php scripts add MODIFY to your IUSR account
    • For asp: add MODIFY to your IWPD account
    • For asp.net: It  will run under your IWPD account by default unless you have impersonation enabled in your web.config (which you should use if using asp.net), in which case it will impersonate the IUSR account - add MODIFY to the appropriate account.
    • For access databases(.mdb files), you might need to give write/modify permission to the file/folder depending on the scripting technology that you're using as given above.
  8. Setting up Access Permissions
    • Allow inheritable permissions from the parent to propagate to this object and all child objects. Include these with entries explicitly defined here --> This check  box will allow you to inherit the permission to child objects from the parent folder.
    • Replace permission entries on all child objects with entries shown here that apply to child objects. -> This will propagate the permission from the current folder to the child folders
  9. Click on  Advanced Options for changing the permissions to allow/deny a user.(For advanced users only)
  10. Click OK to save the change after every action.
Mar 10, 2009 at 2:55 AM
I'm getting this same error hosting on CrystalTech.  I reviewed the security settings and it appears that ASPNET has permissions on the App_Data folder.  Has anyone seen another solution to this issue?
Mar 10, 2009 at 7:00 PM

I would just make sure the hosting company doesn’t have to make it an application folder. That’s always been the case for me. Hope this helps?

Best regards,

Katie Schmidt

Mar 16, 2009 at 2:32 AM
Thanks for the suggestion.  Once the hosting company set it to an application folder it worked fine.