Exception from HRESULT: 0x80070005 (E_ACCESSDENIED)) on local pc - c#

i am using fully asp.net configured site i take it from this link
http://www.codeproject.com/Articles/37660/Fully-configured-ASP-NET-Membership-Website-Templa
as a template to my project, all what i did is changing the conection string on the web.config file to point to my database
<connectionStrings>
<add name="AspNetMembershipTemplateConnectionString" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Members.mdf;Integrated Security=True;User Instance=True" providerName="System.Data.SqlClient"/>
</connectionStrings>
and i run the project locally , but the problem that when i debug it it show this error
Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))
i google it , and i found that happen because of the privileges but i am using my user and its administrator account , how can you help me with this problem?

You are probably having the code in a folder that the IIS account can't access. Move to the wwwroot/Inetpub folder or grant appropriate privileges to the IIS service account for the folder where the code is in.
Edit
I was just reading the exception in the image. When you read the exception thoroughly you will even see that it suggests to edit the privileges.

i use the project in my local pc without needing to use IIS , so i solve this by close VS2012 and reopen it as administrator .. and its work fine

Related

Login failed for user 'IIS APPPOOL\test.bata.com'. when launching ASP.NET Core application from ASP.NET

I am deploying my ASP.NET application on IIS. Everything works well when I run it on Visual Studio with IIS Express but when I use IIS, the event viewer shows this error.
I added a login on SQL Server but still get the same error
Any idea on what I could be missing?
Grand DB_Owner permission for "IIS APPPOOL\test.bata.com". also check the connection string in web.config file
You can try to use custom identity in application pool with the windows user name password and use this string in web.config file.
<add name="umbracoDbDSN" connectionString="data source=YOUR_SERVER_NAME;database=nrc;Integrated Security=SSPI;persist security info=True;" providerName="System.Data.SqlClient" />
For more detailed steps you can refer to this link: https://forums.iis.net/t/1249665.aspx

AccessDenied Exception on AppPool properties, cannot call ApplPool.Recycle() - C#

Running on Windows Server 2012 R2 Standard, with IIS 8.5.9600
In C#, after setting up a site, I'm retrieving the DefaultAppPool from the site.
Upon retrieval of the pool, the following properties have exceptions on them:
appPool.State:
Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))
appPool.WorkerProcesses
at Microsoft.Web.Administration.Interop.IAppHostElement.get_Collection()
at Microsoft.Web.Administration.ConfigurationElement.GetCollection(String collectionName, Type collectionType)
at Microsoft.Web.Administration.ApplicationPool.get_WorkerProcesses()
So I cannot call
AppPool.Recycle()
It throws this exception:
Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))
at Microsoft.Web.Administration.Interop.IAppHostMethodInstance.Execute()
at Microsoft.Web.Administration.ConfigurationMethodInstance.Execute()
at Microsoft.Web.Administration.ConfigurationElement.ExecuteMethod(String methodName)
at Microsoft.Web.Administration.ApplicationPool.Stop()
at EBI.Core.Common.WebHelper.IISHelper.AddApplicationIis7(String serverName, String applicationPool, String siteName, String applicationPath, String virtualDirectoryPath, String physicalPath, String defaultPage, Int32 deploymentType, String siteUrl)
Online research says to add high privileges to this folder:
C:\Windows\System32\inetsrv\config
So I have increasingly added the following:
SYSTEM
Administrators
IIS_IUSRS
INTERACTIVE
NETWORK
SERVICE
DefaultAppPool
NETWORK SERVICE
CREATOR OWNER
IUSR
BUT STILL SAME ERRORS.
It's probably a bad idea to add all those rights to that folder, so perhaps there is something else I might be missing, but I cannot find what it is. Any ideas?
Thanks for any help!
Whether you are trying to access the app-pool from any console application or windows service? If so then the console application or windows service should be executed with a username which has admin rights on the server. The username should also be part of IIS_WPG group. May be I have got your question totally wrong.
If using c# code and deploying to IIS Server then running AppPool.Recycle() can generate 'Access is denied' error.
Visit the application pool you are running the c# code under, and go to advanced Settings -> Identity and change the Identity to 'Administrator' or some user with Admin rights.

Hosting ASP.NET Web App on IIS DB connection problems

I have used IIS before, but I've never used a database and I've never done a web app. I did the same steps for putting a site onto IIS and everything works EXCEPT for when I go to a page that has a DB connection on it. I've tried a lot and this is all I get.
A network-related or instance-specific error occurred while establishing a >connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 50 - Local Database Runtime error occurred. Cannot create an automatic instance. See the Windows Application event log for error details.
Windows Application Event Log:
Cannot get a local application data path. Most probably a user profile is not loaded. If LocalDB is executed under IIS, make sure that profile loading is enabled for the current user.
This was built in Visual Studio and I have a SQL Express DB.
I posted my connection strings, any help is greatly appreciated.
I have added this to my applicationHost.config:
<add name="DefaultAppPool">
<processModel identityType="ApplicationPoolIdentity" loadUserProfile="true" setProfileEnvironment="true" />
And now I get:
An attempt to attach an auto-named database for file |MY DB1 FILE| failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.
<add name="DefaultConnection" connectionString="Data Source=(LocalDb)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\DB1.mdf;Initial Catalog=aspnet-ICCAA_VIZIER-20150223043129;Integrated Security=True" providerName="System.Data.SqlClient"/>
<add name="ConnectionString" connectionString="Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\DB2.mdf;Integrated Security=True;Connect Timeout=30" providerName="System.Data.SqlClient"/>
I was able to figure it out. I changed all my data connections to .\SqlExpress. Which led me to another error of:
Login failed for user ‘NT AUTHORITYNETWORK SERVICE‘
To fix this I followed this guys article to figure it out.
Login Failed For user NetworkService

Windows Azure Web Service, Fails to Connect to SQL Database

I'm working on this for some time and I have no idea anymore what to do.. so here is the problem.
I've got a Azure Webservice, which works perfectly localy. It should connect to a Azure SQL Database (I use the same ConnectionString for debug AND azure.. so it SHOULD be right)
Using IntelliTrace, I find these Errors:
Requested registry access is not allowed.
System.IO.FileNotFoundException Could not load file or assembly 'EntityFramework, Version=6.0.0.0, Culture=Neutral....
System.Data.Entity.Core.ProviderIncompatibleException
System.Data.SqlClient.SqlException A network-related or instance-specific error occured while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct... (This about 50 times)
System.Threading.WaitHandleCannotBeOpenedException No handle of the given name exists.
System.Security.SecurityException Requested registry access is not allowed
Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironmentException error
System.Threading.WaitHandleCannotBeOpenedException No handle of the given name exists.
(Exception stack, top newest, bott oldest)
In my web.config I setup EF and ConnectionString like this:
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="EntityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework" requirePermission="false"/>
</configSections>
<connectionStrings>
<add name="DefaultConnection" connectionString="Server=SERVER.database.windows.net;Database=LeagueMetaDatabase;User ID=USER#ksew7pk8ad;Password=PW;Trusted_Connection=False;Encrypt=True;" providerName="System.Data.SqlClient"/>
</connectionStrings>
I also deactivated "Specific Version" for the EF assembly and activated "Copy Local".
I checked in the bin folder of the service on the server, the dll is there.
The service uses a lot of async, but as already said it works localy.. I also installed .NET 4.5.1 on the server just to be sure that is not the problem
// Edit
First of all, thanks for all the help so far!
I tried narrowing the problem down.. reconstructing the hole project and trying to find what does not work. It seems that async Tasks can NOT read the ConnectionString in the Web.config on the Azure Server Cloud. In the emulator, it works. I hardcoded the ConnectionString into the Context and it is working this way.
Anyone can tell me what creates this behaviour and how I can put it back into the Web.config?
How is your solution deployed to Azure? Are you using a Cloud Service or Web Site? If you're running an Azure Web Site the problem might be related to your connection string name being the same in both the web.config and also your Azure Web Site. If this is the case you might want to try renaming the connection string defined in the Azure Management Portal for you web site. This can be done through the Configure management page.
Hope this helps.
Are the DB & Cloud Service in same data center? If not, link your resources via the Azure control panel and/or make sure that you have enabled "allow azure services to connect" in the DB configure section.
Also, make sure your SERVER connection specifies "tcp" - The Windows Azure SQL Database service is only available with TCP port 1433. To access a SQL Database database from your computer, ensure that your firewall allows outgoing TCP communication on TCP port 1433 (from Guidelines for Connecting to Windows Azure SQL Database). If you grab the ADO connection string from the DB dashboard page, you should see:
Server=tcp:{your_servername}.database.windows.net,1433;Database={your_database_name};User ID={your_userid};Password={your_password_here};Trusted_Connection=False;Encrypt=True;Connection Timeout=30;
First of all, thanks for all the help so far!
I tried narrowing the problem down.. reconstructing the hole project and trying to find what does not work.
It seems that async Tasks can NOT read the ConnectionString in the Web.config on the Azure Server Cloud. In the emulator, it works. I hardcoded the ConnectionString into the Context and it is working this way.
Anyone can tell me what creates this behaviour and how I can put it back into the Web.config?

System.Security.Permissions.SecurityPermission is thrown for Scripting.FileSystemObject

I have added C:\Windows\System32\scrrun.dll as a reference to my web forms application in order to use Interop.Scripting.dll.
It works fine with my local computer.
When I load the application to my production server, I get "System.Security.Permissions.SecurityPermission" exception message, and there is no furher or detailed exception message.The excepiton is thrown for the following line:
Scripting.FileSystemObject fso = new Scripting.FileSystemObject();
Since it is a permission issue, I have also used impersonation in my web.config with Administrator credentials of the server. Bu it did not work.
<identity impersonate="true" userName="Administrator" password="xxxxxx" />
Any help or clue is really welcome, thanks.
close your visual studio and reopen it using admin privilege. Just right click and click on run as administrator. May this will work for you.

Categories

Resources