0

I'm trying to deploy a website in server. But it doesn't work it says user doesn't have permission. I try running it from Visual studio in the same server without any changes it works fine. I am using sql sever authentication, I also set the user as the dbowner.

This is the error message I am Getting:

User does not have permission to perform this action. 
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.Data.SqlClient.SqlException: User does not have permission to    
perform this action.

Source Error: 

An unhandled exception was generated during the execution of the current web request.   
Information regarding the origin and location of the exception can be identified using 
the exception stack trace below.  

Stack Trace: 
[SqlException (0x80131904): User does not have permission to perform this action.]
System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean 
breakConnection) +6333696
System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning() +412
System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler,   
SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject   
stateObj) +1363
System.Data.SqlClient.SqlInternalConnectionTds.CompleteLogin(Boolean enlistOK) +53
System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(ServerInfo serverInfo, 
String newPassword, Boolean redirectedUserInstance, SqlConnection owningObject, 
SqlConnectionString connectionOptions, TimeoutTimer timeout) +6348638
System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection 
owningObject, TimeoutTimer timeout, SqlConnectionString connectionOptions, String 
newPassword, Boolean redirectedUserInstance) +6348553
System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity,   
SqlConnectionString connectionOptions, Object providerInfo, String newPassword, 
SqlConnection owningObject, Boolean redirectedUserInstance) +352
System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions  
options, 
Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection) 
+506
System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection 
owningConnection, DbConnectionPool pool, DbConnectionOptions options) +49
System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject) 
+6350358
System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject) 
+78
System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject) 
+1938
System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection 
owningConnection) +89
System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection 
outerConnection, 
DbConnectionFactory connectionFactory) +6353246
System.Data.SqlClient.SqlConnection.Open() +300
System.Web.DataAccess.SqlConnectionHolder.Open(HttpContext context, Boolean 
revertImpersonate) +150
System.Web.DataAccess.SqlConnectionHelper.GetConnection(String connectionString, 
Boolean 
revertImpersonation) +4712943
System.Web.Security.SqlMembershipProvider.GetPasswordWithFormat(String username, 
Boolean 
updateLastLoginActivityDate, Int32& status, String& password, Int32& passwordFormat, 
String& passwordSalt, Int32& failedPasswordAttemptCount, Int32& 
failedPasswordAnswerAttemptCount, Boolean& isApproved, DateTime& lastLoginDate, 
DateTime& 
lastActivityDate) +3729431
System.Web.Security.SqlMembershipProvider.CheckPassword(String username, String 
password, Boolean updateLastLoginActivityDate, Boolean failIfNotApproved, String& salt, 
Int32& passwordFormat) +189
System.Web.Security.SqlMembershipProvider.ValidateUser(String username, String 
password) 
+202

System.Web.UI.WebControls.Login.AuthenticateUsingMembershipProvider(
AuthenticateEventArgs e) +225
System.Web.UI.WebControls.Login.AttemptLogin() +166
System.Web.UI.WebControls.Login.OnBubbleEvent(Object source, EventArgs e) +93
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +52
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean     
includeStagesAfterAsyncPoint) +3707

How can I fix it?

Sas
  • 2,473
  • 6
  • 30
  • 47
  • This is the answer for the question. [Link][1] [1]: http://stackoverflow.com/questions/8650212/give-aspnetdb-mdf-sql-db-iis-iusrs-permissions – Sas Mar 20 '12 at 16:36

1 Answers1

1

The error is a database permission error. Do you have the appropriate permissions set up on the sql server that the webserver is pointing to? Also, if the connection string is in your web.config file, make sure it is not pointing to your local db instance.

javram
  • 2,635
  • 1
  • 13
  • 18
  • I changed the web.config file to server database instance. I also give the user as dbowner permision. I also have another ASPNETDB.MDF it maintain user roles. I ran the website on the server where I'm deploying the website using Visual studio and it worked fine. – Sas Mar 20 '12 at 14:39
  • Sorry, I couldn't tell from your comment if your original question is now resolved, is it working as expected? – javram Mar 20 '12 at 14:42
  • No it didn't work, I tried to explain the problem in detail as per your question you've asked in your answers. – Sas Mar 20 '12 at 15:06
  • Are you using sql server authentication or windows authentication (Integrated Security=SSPI) to connect to the sql server? – javram Mar 20 '12 at 15:17
  • I am using sql server authentication to connect database. – Sas Mar 20 '12 at 15:19
  • I suspect my login system, which has it own database in Appdata folder, causing the problem. coz I had earlier version of my websit in wich I didn't implement login system. I tried deploying it and it worked fine. – Sas Mar 20 '12 at 15:29
  • The answer: http://stackoverflow.com/questions/8650212/give-aspnetdb-mdf-sql-db-iis-iusrs-permissions – Sas Mar 20 '12 at 19:09