SQL Server Timeout Accessing ASP.NET Profile Provider - asp.net

Hmm, strange one: My ASP.NET 2.0 website all of a sudden starts throwing SQL Server timeout errors. Only solution is to reboot SQL Server. IISRESET on web server doesn't fix it.
Error seems to occur when reading (or writing) from ASP.NET user profile.
If I connect to database directly via SQL Server Management Studio, I can read and write to the aspnet_profile table just fine.
When Googling I discovered one suggestion: to make sure there aren't other providers in machine.config and that I've got a CLEAR element in my web.config to clear those out. Sure enough there were. So my first step was to add in CLEARs in my web.config. Did that and still the error. Then I went into machine.config in the .NET 2.0 area and cleared out the SQLexpress entry and the providers (3 of them). Still no dice.
I want to try and solve the root problem without rebooting the database server.
Note that pages that access the database but not the profile work just fine. BTW, there are 2 connection strings - one for the providers (membership, role, profile, and webparts) and the other for the app data access.
Any suggestions????
Thanks,
Krip

I believe I've solved the problem. The get and set profile properties stored procedures update the LastActivityDate on the aspnet_users table. This was hanging. Not a good idea to have so many unnecessary udpates on users table. I commented that out and all is fine for the moment.

Related

User verification on ASP.NET and MySQL fails on live

I'm not a developer, but need to fix an app that is based on .NET (2.0) and MySQL. I have searched quite a bit, hence the question.
Checked everything on staging, and it seems to be working fine. However, when move to live, users cannot log in. Exact same setup, just change the connection string and connects to the staging database and user log in. I also know that in both circumstances a connection to the database is being made. Users can register and are added to the database.
I believe the same happens when the .NET applications connect to a SQL Server database, however, it is possible to change "applicationname" in the web.config.
So the questions are:
Is there also an "applicationname" change for MySQL?
Could there be anything else causing the problems?

asp.net/sql server/iis permissions

I'm developing an ASP.NET web app that needs to access an SQL Server database. The server the app needs to run on is running Windows Server 2000, SQL server 2000, IIS6, and .NET 2.0.
If I run the web app on my machine with Visual Web Developer 2010 with the testing webserver in Visual studio, but accessing the database on the actual web server, it works fine. However, If I put this app on the actual webserver, and try to access it through the browser, I get a permissions errors saying I don't have access to those tables.
There are two tables my app needs to access. On one of them I changed the permissions with SQL Management Studio to allow the public group select permissions, and that solved the problem. On the other table (very large table) I tried to do the same, but got an error saying it timed out waiting to get a lock on the table. Is there a way to change this timeout or another way to change the permissions?
I don't believe I should even have to change the permissions though, because there are classic ASP apps on that server that access the very same tables. I think the issue is the user that is being used to access the tables. If I can access the tables running the web app from my machine, and classic ASP apps on the server can access them, but my ASP.NET app can't, my ASP.NET app must be using a different user account. How can I check this and make the necessary changes?
Regarding your permission error, it's probably because on your machine the app is accessing the database with your permissions, with windows integrated login.
Normally, a web application is supposed to access a database using a technical user, that is specified in the web.config file, in the connection strings section. It's something like
<configuration>
<connectionStrings>
<add name="myConnsStr" connectionString="server=myserver.example.com;database=mydatabase;uid=tech_account;pwd=tech_account_password" providerName="System.Data.SqlClient" />
</connectionStrings>
...
</configuration>
How does yours look like?
For the other one, yes, do the permission change in T-SQL. If you are not sure how to do that, do the change in the designer, then before clicking OK, use the Script button in the header area. Script the change to the clipboard and then try to run in a new query window. You can play with the query timeouts in the options dialog.
You could try setting the lock timeout to -1 (meaning it'll never timeout)
SET LOCK_TIMEOUT -1
GO
And you can also try adding the permissions using a query
sp_addrolemember #rolename = 'db_datareader', #membername = 'YourAspApp'
You can also try to change your asp.net user in the asp.net connection string to a user which already has selecting privileges.
Let me know if any of that worked, it's a good place to start with =)

How to effectively set up MySQL Users and Roles in the production server WITHOUT Visual Studio?

So far I have been using the WebSite Administration Tool built in Visual Studio 2010 to manage Users and Roles along with MySQL Membership and Roles Provider.
Now, I have deployed the application to the production server and I am getting the following error:
Even if I tried to copy one of the roles and one of the users from my local DB to the one used by the production server, it didn't quite work and I keep getting the same error. At least, I'm sure that's the cause of the error because I did a remote debugging which led me to find it.
At this point I am very confused on how to get it working properly. So, any help or guidance would be really appreciated.
EDIT: At this point the User has been already authenticated in the login page using the connectionString to the production DB server. For that reason, I have dismissed any kind of problems related to the connectionString. I get this error while loading the masterPage where the role is needed in order to choose which menu to display.
The exception message says it all: It cannot connect to the database. Verify that your production DB server is running, that the connection string is correct and that you have network connectivity (including name resolution) from the web server to the DB server.
The solution for this problem was to create the mysql_aspnet_membership provider by granting full access through the machine.config and autogenerating the schema, instead of manually creating the membership tables in the database, which I though there could have been a valid way to create the db.
Afterwards, this didn't break anymore.

IIS7 application using wrong SQL Server 2008 Express database

I'm stumped. I have a client site on a virtual private server - Windows Web Server 2008 SP2, IIS7, SQL Server 2008 Express.
I'm trying to setup a second web application, to allow him to review updates prior to their going live. I've created the web application in IIS7, and I have added a second database to SQL Server. The second db is essentially a copy of the production db, with 'DEV' prefixed to the database name and a few new fields in a few tables.
My production site works fine. However, the test site comes back with an SqlException: "Invalid column name 'version'." This is one of the new fields - which leads me to believe that my dev site is referring to the production database, and not the dev database. Connection strings, however, do point to different databases (although the login is the same for both):
Production site: "Server=.\SQLExpress;Database=myDbName;User ID=myUserName;Password=myUserPassword;"
Dev site: "Server=.\SQLExpress;Database=DEVmyDbName;User ID=myUserName;Password=myUserPassword;"
Seems like this should be something obvious that I'm missing. A colleague suggested that I create another application pool for the second IIS application, but it does not seem to have helped.
UPDATE, following further testing:
I changed the dev site's connection string to
"Server=.\SQLExpress;Database=DEVmyDbName;User ID=devuser;Password=myNewDifferentPassword;"
and created a new SQL server login on the database, and only gave it access to the dev database. I also set the dev database as the account's default database. I removed access to the dev database from the production login. When I try to login to the site, I get the following error:
The server principal "devuser" is not able to access the database "myDbName" under the current security context.
As a result, there are two things I know for certain:
Since it's using the new username to login, I know the app is using the connection string I'm feeding it;
For some reason, once logged in, it appears to be ignoring the specified database and trying to use the production database instead.
I don't think it should make a difference, but I will mention I'm using NHibernate for database access.
Still stumped.
It turns out that NHibernate was significant. One of the NHibernate configuration options that was set was "default_schema" - when I removed it, the app started connecting to the correct database.
It appears that the default_schema property was overriding whatever database was specified in the connection string.

problems with user instance SQL Server 2005 Express mdf file

I have a web app that I am working with on a separate server. I didn't originally create it, but I have to maintain it. I had to to do some manual editing of one of the database tables, which I did through Visual Studio 2008 installed on the same machine. Now I get SQL exceptions regarding Network Service not having the right privileges.
How do I avoid this from happening? I haven't modified any settings regarding the security or access information. It was working before I made the modification, and now it isn't.
Thanks!
Did you by chance change the connection information stored for the DB? Perhaps remove a explicit user (SQL Authentication) and replace it with a Trusted_Connection?
Also did you change the webserver to no longer use authentication?
The error sounds like it is coming from the fact that the Network Service account (the one generally responsible for running ASP.NET pages) cannot access the DB. This happens mostly when authentication is disabled, and there is no explicit SQL Authentication.

Resources