.Net framework 1.1 installed and runs happily UNTIL you try to access anything to do with data.
I've got a c# page, imported all relevent namespaces etc. This runs fine on other servers and my XP Pro machine. However, when put on this server, all I get is
Exception Details: System.UnauthorizedAccessException: Access is denied.
I've tried explictly setting permissions on the file, directory etc, but nothing I've found can get the file to work, yet other c# pages which don't use SQL connections work fine !
The offending line:
Line 31: SqlCommand sqlCmd = new SqlCommand(sql,sqlCon);
Line 32: sqlCon.Open();
Line 33: SqlDataReader datareader = sqlCmd.ExecuteReader();
Line 34: while (datareader.Read()
is line 32.
STACK TRACE:
[UnauthorizedAccessException: Access is denied.]
System.EnterpriseServices.Platform.Initialize() +497
System.EnterpriseServices.ResourcePool..ctor(TransactionEndDelegate cb) +11
System.Data.SqlClient.ConnectionPool..ctor(DefaultPoolControl ctrl) +797
System.Data.SqlClient.PoolManager.FindOrCreatePool(DefaultPoolControl ctrl) +170
System.Data.SqlClient.SqlConnectionPoolManager.GetPooledConnection(SqlConnectionString options, Boolean& isInTransaction) +356
System.Data.SqlClient.SqlConnection.Open() +384
ASP.test_aspx.Page_Load(Object sender, EventArgs e) in C:\Inetpub\wwwroot\fishfood\test.aspx:32
System.Web.UI.Control.OnLoad(EventArgs e) +67
System.Web.UI.Control.LoadRecursive() +35
System.Web.UI.Page.ProcessRequestMain() +731
I've copied this directory and set up another application on another server and it works fine!
Anyone got any ideas?What does your Connection string look like. Is it set up with the correct:
SERVER
PWD
UID
DATABASE
..for this particular server. You haven't by any chance forgotton to change it when deploying your application to server?|||Connection string is fine;
Persist Security Info=False;Data Source=x.x.x.x;Initial Catalog=xxxxxx;User ID=xxxxxx;Password=xxxxxx;"
I tried harding it into the page and using it in the web.config file - makes no difference|||I'm having this exact same problem (except in VB, instead of C#). On my development PC, I'm running W2K Pro, IIS 5, SQL2K Personal Edition, .net Framework v1.1 and I get the error below. But I can execute that exact same page on 2 different remote servers. One is W2K Server with IIS 5 and SQL2K Standard with .net framework v1.1. The other is a W2K3 server with IIS 6 and SQL2K Standard with .net framework v1.1.
Each SQL Server is running in Mixed mode. I'm using the same sql login username/password combo for each of them. Impersonate is set to false in my web.config file.
Here's my error:
Access 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 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 write 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 66: cnn = New SqlConnection("data source=BFRENCH2K;initial catalog=PMD;user id=xxxxxx;password=xxxxxx;")
Line 67: cmd = New SqlCommand("Select * from Admin_Users where Username = '" & Username & "'", cnn)
Line 68: cnn.Open()
Line 69: dr = cmd.ExecuteReader()
Line 70: While (dr.Read())
Source File: C:\Inetpub\wwwroot\SiteDoc\Login.aspx.vb Line: 68
Stack Trace:
[UnauthorizedAccessException: Access is denied.]
System.EnterpriseServices.Platform.Initialize() +497
System.EnterpriseServices.ResourcePool..ctor(TransactionEndDelegate cb) +11
System.Data.SqlClient.ConnectionPool..ctor(DefaultPoolControl ctrl) +797
System.Data.SqlClient.PoolManager.FindOrCreatePool(DefaultPoolControl ctrl) +170
System.Data.SqlClient.SqlConnectionPoolManager.GetPooledConnection(SqlConnectionString options, Boolean& isInTransaction) +358
System.Data.SqlClient.SqlConnection.Open() +384
SiteDoc.Login.ValidateUser(String Username, String Password) in C:\Inetpub\wwwroot\SiteDoc\Login.aspx.vb:68
SiteDoc.Login.btnLogin_Click(Object sender, EventArgs e) in C:\Inetpub\wwwroot\SiteDoc\Login.aspx.vb:49
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +57
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
System.Web.UI.Page.ProcessRequestMain() +1266|||I located an article that had a solution for my problem.
http://www.experts-exchange.com/Programming/Programming_Languages/Dot_Net/Q_20850586.html
Check to make sure that the following file has permissions on the ASPNET account:
C:\winnt\system32\com\comadmin.dll
I gave the aspnet account permission to read that file and everything works fine now.|||Thank you
It has solved my Problem.
I was having the same problem.
It was working fine on my machine but when I deployed the project and database to Live server it was giving the error.|||None of the solutions above worked for me.
Instead, I've changed the security settings for the windows account (machine_name\users) to Full Control and grant access to the folder. Obviously the permissions were changed for that folder only.
My asp.net utility is an upload tool and all files uploaded stores themselves into it. Folder is named /imgs/.
I realized today (just today !) of this problem. Last days my webapp worked fine, but I don't know what happened. Maybe some new software just installed, maybe some strange Windows behavior, maybe...??
I think this solution is not secure, because everybody have access to that folder, am I wrong ?
Hope this work, because none of the solutions here, neither in other websites worked.
Sorry for my strange english.
Bye.
No comments:
Post a Comment