Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 622
  • Last Modified:

ASP.NET Memberships Database

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
rrhandle8
Asked:
rrhandle8
  • 8
  • 7
1 Solution
 
guru_samiCommented:
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
 
rrhandle8Author Commented:
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
 
guru_samiCommented:
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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
rrhandle8Author Commented:
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
 
guru_samiCommented:
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
 
rrhandle8Author Commented:
If I find the  machine.config's connectionstrings, what do I use in place of LocalSqlServer?
0
 
guru_samiCommented:
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
 
rrhandle8Author Commented:
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
 
guru_samiCommented:
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
 
rrhandle8Author Commented:
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
 
rrhandle8Author Commented:
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
 
guru_samiCommented:
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
 
guru_samiCommented:
0
 
rrhandle8Author Commented:
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
 
guru_samiCommented:
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 8
  • 7
Tackle projects and never again get stuck behind a technical roadblock.
Join Now