Improve company productivity with a Business Account.Sign Up


ASP.NET Memberships Database

Posted on 2009-07-09
Medium Priority
Last Modified: 2012-05-07
I used Visual Web developer 2008 to create a web site that uses the built-in ASP.NET Membership functionality to create users and roles.  Works perfect on my my computer, but when moved to the web site (my VPS), I get the following error:

Failed to generate a user instance of SQL Server due to failure in retrieving the user's local application data path. Please make sure the user has a local user profile on the computer. The connection will be closed.
Question by:rrhandle8
  • 8
  • 7
LVL 41

Expert Comment

ID: 24819159
My doubt is it is failing to connect to you DB or some ASPNET/ NetworkService User account permission.
I would suggest to make sure your connectionString is corret and pointing to the correct Database.
How did you upload your membership DB to your server?

share your web.config connectionstring / membership provider info.

Author Comment

ID: 24820133
There is no web.config connectionstring
Where do I find: membership provider info.

The error has changed to this:
An attempt to attach an auto-named database for file C:\Inetpub\vhosts\\subdomains\mft\httpdocs\App_Data\mft_aspnetdb.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.

Notice I tried to rename the database, but that did not help.
LVL 41

Expert Comment

ID: 24823728
The default membership settings are from your machine.config.
It uses connectionStringName = LocalSqlServer ...i.e. in your machine.config's connectionstrings can find this LocalSqlServer connectionString.
One more question...are you using SqlExpress DB or other Sql Sever?
Check this for more info:
The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!


Author Comment

ID: 24825026
sami, from what I understand, my problem is that I am trying to use it on my VPS, and you cannot use SQL Express on a web site.  Is that correct?  If it is, that answers my question.
LVL 41

Expert Comment

ID: 24825326
You can use SQL Express on your server as well and your website can use it.
I only doubt that there might be some DB connection/permission issue.

Author Comment

ID: 24825354
If I find the  machine.config's connectionstrings, what do I use in place of LocalSqlServer?
LVL 41

Expert Comment

ID: 24825467
In your web.config add the following. It will override the machine.config LocalSqlServer connectionString settings.
        <remove name=LocalSqlServer/>
        <add name="LocalSqlServer" connectionString="ConnectionStringToYourASPNETDB on your Server" providerName="System.Data.SqlClient"/>


Author Comment

ID: 24828525
I did as you said.  It got me past the current error, but now I get this:

Format of the initialization string does not conform to specification starting at index 0.

        <remove name="LocalSqlServer"/>
        <add name="LocalSqlServer" connectionString="C:\Inetpub\vhosts\\subdomains\mfft\httpdocs\App_Data\ASPNETDB.mdf" providerName="System.Data.SqlClient"/>
LVL 41

Expert Comment

ID: 24828847
If your DB is in app_Data Folder then using local sql Express instance  the default in machine.config should work.....still try replacing your connectionString like below...

<add name="LocalSqlServer" connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=true" providerName="System.Data.SqlClient"/>

Also if you ge the same error again...check the event log and see if there is any other permission related error message...      

Author Comment

ID: 24828882
Now I get this error, which I have had before.
An attempt to attach an auto-named database for file C:\Inetpub\vhosts\\subdomains\mft\httpdocs\App_Data\aspnetdb.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.

Author Comment

ID: 24828907
This is from the event viewer.

Event code: 3005
Event message: An unhandled exception has occurred.
Event time: 7/10/2009 11:08:00 PM
Event time (UTC): 7/11/2009 3:08:00 AM
Event ID: 45151ec0fa74466f96c133f7693aabaf
Event sequence: 2
Event occurrence: 1
Event detail code: 0
Application information:
    Application domain: /LM/W3SVC/8348/Root-2-128917552801115006
    Trust level: Full
    Application Virtual Path: /
    Application Path: C:\Inetpub\vhosts\\subdomains\mft\httpdocs\
    Machine name: CT3237
Process information:
    Process ID: 16624
    Process name: w3wp.exe
Exception information:
    Exception type: SqlException
    Exception message: An attempt to attach an auto-named database for file APP_DATA/aspnetdb_mft.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.
Request information:
    Request URL: unhandled exception has occurred.fmembersAn unhandled exception has occurred.fDefault.aspx
    Request path: /login.aspx
    User host address:
    Is authenticated: False
    Authentication Type:  
    Thread account name: NT AUTHORITY\NETWORK SERVICE
Thread information:
    Thread ID: 10
    Thread account name: NT AUTHORITY\NETWORK SERVICE
    Is impersonating: False
    Stack trace:    at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)
   at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)
   at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
   at System.Data.SqlClient.SqlInternalConnectionTds.CompleteLogin(Boolean enlistOK)
   at System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, Boolean ignoreSniOpenTimeout, Int64 timerExpire, SqlConnection owningObject)
   at System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(String host, String newPassword, Boolean redirectedUserInstance, SqlConnection owningObject, SqlConnectionString connectionOptions, Int64 timerStart)
   at System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection owningObject, SqlConnectionString connectionOptions, String newPassword, Boolean redirectedUserInstance)
   at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, String newPassword, SqlConnection owningObject, Boolean redirectedUserInstance)
   at System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection)
   at System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection owningConnection, DbConnectionPool pool, DbConnectionOptions options)
   at System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject)
   at System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject)
   at System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject)
   at System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection)
   at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)
   at System.Data.SqlClient.SqlConnection.Open()
   at System.Web.DataAccess.SqlConnectionHolder.Open(HttpContext context, Boolean revertImpersonate)
   at System.Web.DataAccess.SqlConnectionHelper.GetConnection(String connectionString, Boolean revertImpersonation)
   at 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)
   at System.Web.Security.SqlMembershipProvider.CheckPassword(String username, String password, Boolean updateLastLoginActivityDate, Boolean failIfNotApproved, String& salt, Int32& passwordFormat)
   at System.Web.Security.SqlMembershipProvider.CheckPassword(String username, String password, Boolean updateLastLoginActivityDate, Boolean failIfNotApproved)
   at System.Web.Security.SqlMembershipProvider.ValidateUser(String username, String password)
   at System.Web.UI.WebControls.Login.AuthenticateUsingMembershipProvider(AuthenticateEventArgs e)
   at System.Web.UI.WebControls.Login.OnAuthenticate(AuthenticateEventArgs e)
   at System.Web.UI.WebControls.Login.AttemptLogin()
   at System.Web.UI.WebControls.Login.OnBubbleEvent(Object source, EventArgs e)
   at System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args)
   at System.Web.UI.WebControls.Button.OnCommand(CommandEventArgs e)
   at System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument)
   at System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
   at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
   at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
   at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
Custom event details:

For more information, see Help and Support Center at
LVL 41

Expert Comment

ID: 24828929
Sorry rrhandle8 ...i am not sure whats happening as I have always been using sql Server 2005 but one thing I overlooked in your previous connectionString is your connectionString was not in right format ..
when you got the error:
"Format of the initialization string does not conform to specification starting at index 0. "
It should be something like below:

<add name="LocalSqlServer" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Inetpub\vhosts\\subdomains\mfft\httpdocs\App_Data\ASPNETDB.mdf;Integrated Security=True;User Instance=True" providerName="System.Data.SqlClient"/>

Try and see if it makes any difference....sorry about this confusion.
LVL 41

Expert Comment

ID: 24828943

Author Comment

ID: 24829001
Been to that link more than a few times over the last 5 days.
Client just cancelled the project, and awarded it to someone who put up a role based web site from him in under an hour using PHP and MySql.  He had a few colorful things to say about me and Microsoft.

I would still like to understand what is going on here.  This is the longest time I have spent trying to debug something, and it has gotten under my skin.  The web is full of people having problems with this feature in ASP.NET.  Is this one of those situations where Microsoft is not the solution?
LVL 41

Accepted Solution

guru_sami earned 750 total points
ID: 24829024
did you tried the last connectionstring i gave...
As I said ..I haven't come across that error...nor I know how to replicate since I use Sql Server Standard not able to help you at the fullest ..but just used my knowledge about using membership provider to see if it works.
Sorry about that.

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
User art_snob ( encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
In the video, one can understand the process of resizing images in single or bulk. Kernel Bulk Image Resizer is an easy to use tool for resizing large number of images. One can add and resize multiple images with this tool in single go. The video sh…
If you are looking for an automated tool which can generate reports for Outlook emails and other items from PST file, then you can go for Kernel PST Reporter tool. The reports which are created by this tool are helpful to analyze and understand PST …

585 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question