locked
Access denied to database in app_data folder RRS feed

  • Question

  • User-1327394822 posted

    I have hosted an application but the page which accesses the database is throwing the following error. The permission to the folder(app-data) and the database file are given as "full control"...

    This is the page: http://fashionyatra.in/AllEvents/all

    Server Error in '/' Application.


    Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))

    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 is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED)) 

    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 and IIS 7, and the configured application pool identity on IIS 7.5) 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 File 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: 

    [UnauthorizedAccessException: Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))]
       System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo) +0
       System.Data.SqlServerCe.UnmanagedLibraryHelper..ctor(String fileName) +53
       System.Data.SqlServerCe.NativeMethodsHelper..ctor(String modulePath) +27
       System.Data.SqlServerCe.NativeMethods.LoadValidLibrary(String modulePath) +372
       System.Data.SqlServerCe.NativeMethods.LoadNativeBinariesFromPrivateFolder(String privateInstall) +76
       System.Data.SqlServerCe.NativeMethods.LoadNativeBinaries() +219
       System.Data.SqlServerCe.SqlCeConnection..ctor() +12
       System.Data.SqlServerCe.SqlCeProviderFactory.CreateConnection() +19
       WebMatrix.Data.DbProviderFactoryWrapper.CreateConnection(String connectionString) +82
       WebMatrix.Data.<>c__DisplayClass15.<OpenConnectionStringInternal>b__14() +16
       WebMatrix.Data.Database.get_Connection() +19
       WebMatrix.Data.Database.EnsureConnectionOpen() +13
       WebMatrix.Data.<QueryInternal>d__0.MoveNext() +67
       System.Collections.Generic.List`1..ctor(IEnumerable`1 collection) +381
       System.Linq.Enumerable.ToList(IEnumerable`1 source) +58
       WebMatrix.Data.Database.Query(String commandText, Object[] parameters) +98
       ASP._Page_Shared__Events_cshtml.Execute() in d:\inetpub\vhosts\iwiz.in\fashionyatra.in\Shared\_Events.cshtml:13
       System.Web.WebPages.WebPageBase.ExecutePageHierarchy() +199
       System.Web.WebPages.WebPage.ExecutePageHierarchy(IEnumerable`1 executors) +69
       System.Web.WebPages.WebPage.ExecutePageHierarchy() +131
       System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +90
       System.Web.WebPages.<>c__DisplayClass7.<RenderPageCore>b__6(TextWriter writer) +231
       System.Web.WebPages.HelperResult.WriteTo(TextWriter writer) +10
       System.Web.WebPages.WebPageBase.Write(HelperResult result) +80
       ASP._Page_AllEvents_cshtml.Execute() in d:\inetpub\vhosts\iwiz.in\fashionyatra.in\AllEvents.cshtml:6
       System.Web.WebPages.WebPageBase.ExecutePageHierarchy() +199
       System.Web.WebPages.WebPage.ExecutePageHierarchy(IEnumerable`1 executors) +69
       System.Web.WebPages.WebPage.ExecutePageHierarchy() +131
       System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +78
       System.Web.WebPages.WebPageHttpHandler.ProcessRequestInternal(HttpContextBase httpContext) +116

    Thursday, February 12, 2015 1:39 AM

Answers

  • User-821857111 posted

    The permission to the folder(app-data) and the database file are given as "full control"
    Which user account have you given that permission to? Is it the app pool user account? If not, you probably need to give MODIFY permission to IIS APPPOOL\Your_App_Pool_Name.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, February 12, 2015 2:00 AM

All replies

  • User-821857111 posted

    The permission to the folder(app-data) and the database file are given as "full control"
    Which user account have you given that permission to? Is it the app pool user account? If not, you probably need to give MODIFY permission to IIS APPPOOL\Your_App_Pool_Name.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, February 12, 2015 2:00 AM
  • User-1716253493 posted

    Have you follow the instruction?

    Thursday, February 12, 2015 2:07 AM
  • User-1327394822 posted

    Thankyou Mike! 

    There are 2 scenarios I faced. I am on a shared hosting, I have access through plesk. As per plesk:

    1) mywebsite> filemanager > app_data(folder, change permissions) gave "full control" to the 2 accounts a) Plesk IIS Anonymous Account (IUSR_iwizi7zu) b) Plesk IIS Worker Process Identity Account (IWPD_245(iwizi7zu))

    The above dint work. The above was suggested my the hosting support.

    After reading your post I went to 

    2) mywebsite > virtual directories > directory access permisson > gave full control to the same above 2 accounts

    any idea whats the difference? 

    Thursday, February 12, 2015 2:53 AM
  • User-821857111 posted

    You can add

    @Environment.UserName

    to a page and then run it to see which user account your site is running under.

    Thursday, February 12, 2015 3:18 AM
  • User311508580 posted

    Hi Gautam,

    If it doesnt work, please just ask your support team to give the full permission for you. You wont see this error anymore. :)

    Friday, February 13, 2015 12:16 AM