Solved

ASP.NET Memberships Database

Posted on 2009-07-09
15
612 Views
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.
0
Comment
Question by:rrhandle8
  • 8
  • 7
15 Comments
 
LVL 41

Expert Comment

by:guru_sami
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.
0
 

Author Comment

by:rrhandle8
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\inomax.net\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.
0
 
LVL 41

Expert Comment

by:guru_sami
ID: 24823728
The default membership settings are from your machine.config.
It uses connectionStringName = LocalSqlServer ...i.e. in your machine.config's connectionstrings section..you can find this LocalSqlServer connectionString.
One more question...are you using SqlExpress DB or other Sql Sever?
Check this for more info:
http://weblogs.asp.net/scottgu/archive/2005/08/25/423703.aspx
http://www.asp.net/learn/security/tutorial-04-vb.aspx
0
 

Author Comment

by:rrhandle8
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.
0
 
LVL 41

Expert Comment

by:guru_sami
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.
0
 

Author Comment

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

Expert Comment

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

0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:rrhandle8
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.

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

Expert Comment

by:guru_sami
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...      
0
 

Author Comment

by:rrhandle8
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\inomax.net\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.
0
 

Author Comment

by:rrhandle8
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\inomax.net\subdomains\mft\httpdocs\
    Machine name: CT3237
 
Process information:
    Process ID: 16624
    Process name: w3wp.exe
    Account name: NT AUTHORITY\NETWORK SERVICE
 
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: http://mft.inomax.net/login.aspx?ReturnUrl=An unhandled exception has occurred.fmembersAn unhandled exception has occurred.fDefault.aspx
    Request path: /login.aspx
    User host address: 69.77.187.254
    User:  
    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 http://go.microsoft.com/fwlink/events.asp.
0
 
LVL 41

Expert Comment

by:guru_sami
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\sinomax.net\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.
0
 
LVL 41

Expert Comment

by:guru_sami
ID: 24828943
0
 

Author Comment

by:rrhandle8
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?
0
 
LVL 41

Accepted Solution

by:
guru_sami earned 250 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 edition...so 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.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…

863 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now