MVC3 out of the box membership provider (log on) not working on newly published server?
I just published my mvc3 application that uses the default membership provider to login but it seems that the call to anything "Membership" (Membership.ValidateUser-in this case) is causing the following error on the remote server hosting my web application.
Server is 2003 SP2 IIS6.0...my mvc3 application hits sql server 2008 instance.
A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified开发者_Go百科)
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
SQLExpress database file auto-creation error:
How is the out of the out of the box (new mvc3 app) user/login managed with MVC3 and how can I set this user store up on my remote IIS server?
By default it creates a connection to a local SQL Express db in your App_Data folder the first time you run the mvc web app and register a user. You will then notice the aspnetdb file is created.
If you wish to use your existing db you need to create the Membership schema on an existing database.
<connectionStrings>
<add name="ApplicationServices"
connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=true"
providerName="System.Data.SqlClient" />
</connectionStrings>
Easiest way is to update the web.config connection string to point to new db and run the install scripts agaist this.
These scripts are located in the WINDIR%\Microsoft.Net\Framework\v2.0.50727\ folder with names like InstallCommon.sql, InstallMembership.sql, InstallRoles.sql, InstallProfile.sql, InstallSqlState.sql, and so on.
See this more in depth article for full overview
http://www.asp.net/security/tutorials/creating-the-membership-schema-in-sql-server-cs
精彩评论