Yes, you will need to change your connection strings in the web.config file.
Look in web.config, you will probably see something like this in the <membership> element:
<membership> <providers> <clear /> <add connectionStringName="LocalSqlServer" name="AspNetSqlMembershipProvider" [...] type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /> </providers> </membership>
The connectionStringName attribute tells the infrastructure to look for a <connectionStrings> string called "LocalSqlServer" in your <connectionStrings> element - this may not be defined in your web.config, as it can be inherited from Machine.Config in .Net Frameworks.
You should probably choose a new name for the connection string and update your memberships, roles and profile (if you use all of them) to use the new name.
Then in the <connectionStrings> element there is the following:
<connectionStrings> <remove name="LocalSqlServer" /> <add name="MyConnectionString" connectionString="Data Source=[ServerName];Initial Catalog=[DatabaseName];Integrated Security=True" providerName="System.Data.SqlClient" /> </connectionStrings>
Adjust the values according to your systems - I would recommend Integrated Security to store the login and password in the database in web.config, but YMMV (for example, on my shared host, I can not use Integrated Security, so I need to provide user information / Aisle).
The website administration tool will also abide by these connection strings.
Change response to comment
Have you successfully logged in? Or created a user? I just want to exclude that the connection string is configured and working?
Do you have a customized and enabled role provider? Have you updated the connectionStringName attribute?
Note that, as before, machine.config indicates the default role provider for you, which is trying to point to a local SqlExpress instance, which is probably the cause of the connection error.
<roleManager enabled="true"> <providers> <clear /> <add connectionStringName="MyConnectionString" [...] type="System.Web.Security.SqlRoleProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /> </providers> </roleManager>
For more information about canceled attributes, I would recommend the documentation:
Once you have configured this, everything should work.
If you could not create a user / log in, I would check:
- Connection string - make sure that the names match, make sure that the
data source matches your server instance (not always just the name of your computer, it can be something like "MachineName \ SqlServer"). - If you use integrated protection, you need to make sure that you indicate that your site operates under the appropriate rights in the database: you should find that there are several roles in your database, starting with
aspnet_ , so that you can create users (which you if you have a registration form), you must add an account in the role of aspnet_XXXX_FullAccess (one for membership, personalization, profile and roles).