Solved

ASP.NET Memberships Database

Posted on 2009-07-09
15
611 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
If I find the  machine.config's connectionstrings, what do I use in place of LocalSqlServer?
0
 
LVL 41

Expert Comment

by:guru_sami
Comment Utility
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
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 

Author Comment

by:rrhandle8
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
0
 

Author Comment

by:rrhandle8
Comment Utility
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
Comment Utility
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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

762 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

10 Experts available now in Live!

Get 1:1 Help Now