Joining Asp.Net Using ASP.NET Website Administration Tool

I created a database with aspnet_regsql, the database was created in sql sever 2008, and not in the data folder in my project (do I need to move it to the folder manually?).
Then, in the Website Administration Tool, I went to the "Provider" section and clicked the "Skip Test" button.

There was an error:

Failed to establish database connection. If you have not created a SQL Server database yet, the website administration tool has come out, use the aspnet_regsql command-line utility to create and configure the database, and then return to this tool to install the provider.

Perhaps I need to install something in the web.config file, for example, membership settings or connection strings (or should the ASP.NET website admin tool create these settings for me)?

Update:
Maybe this happens because I'm using SQL Server 2008 full and not expressing it?

Update 2:

After installing the membership section and connection string in my aspnetdb database in the Website Administration Tool, I opened security-> Security Configuration Wizard-> Define Roles (step 4). I got this error:

An error has occurred. Return to the previous page and try again.

The following message may help diagnose the problem: Cannot connect to the SQL Server database. in System.Web.Administration.WebAdminPage.CallWebAdminHelperMethod (Boolean isMembership, String methodName, Object [], Type [] paramTypes) in ASP.security_wizard_wizardpermission_ascx.OnInit (EventArgs is System.Web.UI.Control.InitCreven .Web.UI.Control.InitRecursive (Control namingContainer) in System.Web.UI.Control.InitRecursive (Control namingContainer) in System.Web.UI.Control.InitRecursive (Control namingContainer) in System.Web.UI.Control.InitRecursive (Control namingContainer) in System.Web.UI.Page.ProcessRequestMain (Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

+4
source share
4 answers

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.

 <!-- Note enabled="true" - you need to turn this one on! --> <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).
+5
source

Open sql management studio and open the main database, create a new query and enter

 sp_configure 'user instances enabled','1' 

do it then enter

 reconfigure 

and do this for the changes to take effect. For more information about sp_configure, you can read http://msdn2.microsoft.com/en-us/library/ms188787.aspx if you want to list the entire configuration and then run sp_configure without any parameters.

0
source

Follow the instructions below. For proper integration of membership on your site (if you see the above error, for example

" Could not establish a connection to the database. If you have not yet created the SQL Server database, exit the Web Site Administration tool, use the aspnet_regsql command-line utility to create and configure the database, and then return to this tool to set the provider . " )

step 1:

Run the aspnet_regsql.exe utility from the folder C: \ windows \ Microsoft.NET \ Framework \ v2.0.50727 on your computer. When you select or double-click the aspnet_regsql.exe utility, a wizard opens, as shown below.

enter image description here

The next Next window opens in the window that appears, where you can configure SQL Server services for applications or delete information about application services from an existing database.

step 2:

Select the SQL Server configuration for connecting application services to install the new database, and click Next.

enter image description here

Step 3

Enter the SQL Express server name as shown below. Note that you can change the name of the application services database to the desired name (aspnetdb by default). (Or) you can choose Sql Server authentication (username, password, corresponding database name)

Note that I named the ASPNETServices database

enter image description here

Step 4:

Select "Next" and confirm that your settings are correct in order to continue the installation (shown in the figure below) and click the "Next" button.

enter image description here

Step 5

Selecting the next button in the window above will bring up a confirmation window, as shown below, after successfully installing your ASP.NET application database. Finally click Finish.

enter image description here

Step 6

You will see that the installed ASPNET service database is ready for use in your ASP.NET application enter image description here

0
source

I had similar problems since this is my first experience with asp.net membership. If you set <roleManager Enabled="False" /> , you can proceed to create users.

I assume that here, but I think the additional provider in web.config for AspNetSqlRoleProvider and giving it a connection string that points to the asp services database with a user who is configured to access information about the management role on the SQL side (view properties sql user for "schemas belonging to this user" and "Membership in the database role") will allow the tool to correctly enter the database.

Are you using Windows authentication or SQL authentication on your SQL Server?

PS -

The more I read and understand Zhafi’s answers, the more I like it. He gave a link to the msdn schema for the AspNetSqlRoleProvider element (don’t be fooled by Microsoft, saying that the document does not exist, just select the appropriate version from the “other versions” dropdowns).

Update I did something bad in the publication here, before actually checking what I was writing, but I did it, and adding the following to web.config, I let me continue to edit users and add / manage roles.

 <roleManager enabled="true"> <providers> <clear/> <add name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" connectionStringName="MyConnectionString"/> </providers> </roleManager> 

as I mentioned earlier, the user specified in my connection string needs the properties of aspnet_Roles _... Access, as well as aspnet_Membership _... Access, unless you use integrated security=true along with <identity impersonate="true" userName="windowsUser" password="winUsrPassword" /> , in which case your user needs these properties.

0
source

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


All Articles