Change the connection string to an ASP.NET website

I have created user roles with the Asp.net content management tool . I want to keep these user roles in my table, which are stored on the SQL server. But the tool created a default connection string and saved the data in its table.

I have a user_role table with attributes user_id , role_id and role_name in SQL Server 2008 R2. How to connect this table to asp.net website administration tool?

I am using the .NET framework 4.0, ASP.net web application, SQL Server 2008 R2.

+4
source share
1 answer

The default configuration is defined in your web.config application file here:

 <configuration> <connectionStrings> <add name="ApplicationServices" connectionString="data source=SERVERNAME;Initial Catalog=aspnetdb;User Id=yourusername;Password=yourpassword" providerName="System.Data.SqlClient"/> </connectionStrings> <system.web> <membership> <providers> <clear/> <add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="ApplicationServices" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="4" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="/"/> </providers> </membership> 

The <connectionStrings> section will show where you are connecting to the database, and the <membership> section will show how your membership provider is configured.

So it looks like you just need to change the connection string to point to the database that you configured (instead of the default aspnetdb ).

+3
source

Source: https://habr.com/ru/post/1387061/


All Articles