7.2 Web Providers

The MySQL Application Configuration tool establishes MySQL as the database provider for one or more web providers by making changes to your application's Web.config file. You can choose only one of the two membership providers: membership or simple membership. All of the other web providers may be enabled independently or together. The configuration entries for each web provider managed by the MySQL Application Configuration tool are included in the sections that follow.

Web-provider pages share several common elements, as the membership provider page shows.

Figure 7.4 MySQL Application Configuration Tool - Membership

Content is described in the surrounding text.

Check box to enable the provider.  Web providers are enabled when you select the check box on the page. When selected, the page enforces requirement-checking specific to the provider. For example, if you enable any provider, the configuration file for you application must include a connection string. If the connection string is missing, the tool returns a warning when you attempt to move to the next provider. To skip (or disable) an individual web provider, deselect the check box.

Name.  Each enabled web provider requires a value to specify the application name. If you do not provide a value, then the default value creates an application name for you. The value is associated with the applicationName property in the Web.config file.

Connection String.  The Web.config file stores a single connection string for all of the MySQL web-providers. Each web-provider page includes an area for entering a connection string, however only the last entry is saved. For example, if you set it in the first web provider and also set it on the third web provider, the connection string from the third provider page is saved. You can enter a connection string directly in the text box provided or click Edit to use a visual editor to help you sort and select the various connection string options (see Section 7.3, “Using the MySQL Connection String Editor” ).

Autogenerate Schema.  Select the Autogenerate Schema option check box to ensure that the necessary schemas are created automatically for the web provider being configured. These schemas are used to store MySQL web provider information. The database used for storage is the one specified in the connection string.

Write exceptions to event log.  Select the Write exceptions to event log option check box to ensure that exceptions generated by the application are written to the Windows event log.

Membership Provider

In addition to the standard membership provider, there is also a simple membership provider. You can only choose one of these two membership providers. To use the membership provider, select Use MySQL to manage my membership records to enable the page. You can now enter the name of the application that you are creating the configuration for. You can also enter a description for the application. The Autogenerate Schema and Write exceptions to event log options can be selected for this web provider.

After setting up a membership provider, a new section is added to the web configuration file.

<membership defaultProvider="MySQLMembershipProvider">

      <providers>

        <remove name="MySQLMembershipProvider" />

        <add name="MySQLMembershipProvider" type="MySql.Web.Security.MySQLMembershipProvider, 
          MySql.Web, Version=8.0.18.0, Culture=neutral, PublicKeyToken=c2222fc22222c44d"
          applicationName="/" description="MySQL default application" connectionStringName="LocalMySqlServer" 
          writeExceptionsToEventLog="False" autogenerateschema="False" enableExpireCallback="False" 
          enablePasswordRetrieval="False" enablePasswordReset="True" requiresQuestionAndAnswer="True" 
          requiresUniqueEmail="False" passwordFormat="Clear" maxInvalidPasswordAttempts="5" 
          minRequiredPasswordLength="7" minRequiredNonalphanumericCharacters="1" passwordAttemptWindow="10" 
          passwordStrengthRegularExpression="" />

      </providers>

</membership>

With one of the membership providers configured, click Next to advance to the roles provider page.

Simple Membership Provider

The simple membership provider options are similar to those of the membership provider, but with fewer properties in the configuration file. To enable, check the Use MySQL to manage my simple membership records.

Note

The simple membership provider is not supported by MySQL Connector/NET 8.0 and cannot be enabled if you have the 8.0 version of the connector installed.

The MySQL simple membership provider handles the website membership tasks with ASP.NET. This provider is a simpler version of the ASP.NET Membership provider, and it can also work with OAuth Authentication. For additional information about using OAuth authentication, see Adding OAuth Authentication to a Project.

The required configuration options for the simple membership provider are: a name for the connection string and a connection string that contains a valid database with a local or remote MySQL server instance, a user table to store the credentials, and column names for the User ID and User Name columns.

Select the Auto Create Tables option to create the required tables when adding the first user to the table. After setting up a membership provider, a new section is added to the web configuration file.

<membership defaultProvider="MySQLSimpleMembershipProvider">

      <providers>

        <clear />

        <remove name="MySQLSimpleMembershipProvider" />

        <add name="MySQLSimpleMembershipProvider" 
          type="MySql.Web.Security.MySQLSimpleMembershipProvider, MySql.Web, Version=6.10.8.0, Culture=neutral, 
          PublicKeyToken=c2222fc22222c44d" 
          applicationName="/" description="MySQL default application" 
          connectionStringName="LocalMySqlServer" 
          writeExceptionsToEventLog="False" 
          autogenerateschema="False" 
          enableExpireCallback="False" 
          userTableName="Users" 
          userIdColum="UserId" userNameColum="UserName" autoGenerateTables="True" />

      </providers>

</membership>

After setting up one of the membership providers, click Next to configure the roles provider page.

Roles Provider

Click Use MySQL to manage my roles to enable this provider page. The page includes the following options to edit: the connection string, the application name, and a description of the provider. The Autogenerate Schema and Write exceptions to event log options can be selected for this web provider.

After setting up a roles provider, a new section is added to the web configuration file.

<roleManager defaultProvider="MySQLRoleProvider">

      <providers>

        <remove name="MySQLRoleProvider" />

        <add name="MySQLRoleProvider" type="MySql.Web.Security.MySQLRoleProvider, MySql.Web, Version=8.0.18.0, Culture=neutral, 
          PublicKeyToken=c2222fc22222c44d" 
          applicationName="/" description="" connectionStringName="LocalMySqlServer" 
          writeExceptionsToEventLog="False" autogenerateschema="False" enableExpireCallback="False" />

      </providers>

</roleManager>

Click Next to configure the profiles provider page.

Profiles Provider

Click Use MySQL to manage my profiles to enable this provider page. The page includes the following options to edit: the connection string, the application name, and a description of the provider. The Autogenerate Schema, Write exceptions to event log, and Callback for session end event options can be selected for this web provider.

After setting up a profiles provider, a new section is added to the web configuration file.

<profile defaultProvider="MySQLProfileProvider">

      <providers>

        <remove name="MySQLProfileProvider" />

        <add name="MySQLProfileProvider" type="MySql.Web.Profile.MySQLProfileProvider, MySql.Web, Version=8.0.18.0, 
          Culture=neutral, PublicKeyToken=c2222fc22222c44d" 
          applicationName="/" description="" connectionStringName="LocalMySqlServer" 
          writeExceptionsToEventLog="False" autogenerateschema="False" enableExpireCallback="False" />

      </providers>

</profile>

Click Next to configure the session state provider page.

Session State Provider

Click Use MySQL to manage my ASP.Net session state to enable this provider page. The page includes the following options to edit: the connection string, the application name, and a description of the provider. The Autogenerate Schema and Write exceptions to event log options can be selected for this web provider.

After setting up a session provider, a new section is added to the web configuration file.

<sessionState mode="Custom" cookieless="true" regenerateExpiredSessionId="true" customProvider="MySqlSessionStateProvider">

      <providers>

        <add name="MySqlSessionStateProvider" type="MySql.Web.SessionState.MySqlSessionStateStore, MySql.Web, 
          Version=8.0.18.0, Culture=neutral, PublicKeyToken=c2222fc22222c44d" 
          applicationName="/" description="" connectionStringName="LocalMySqlServer" 
          writeExceptionsToEventLog="False" autogenerateschema="False" enableExpireCallback="False" />

      </providers>

</sessionState>

Click Next to configure the site map provider page.

Site Map Provider

The site map provider builds a site map from a MySQL database, and builds a complete tree of the SitemapNode objects. It also provides methods so that the generated nodes can be read from the site map. Click Use MySQL to manage my ASP.NET site map to enable this provider page.

The required configuration options: A name for the application and a connection string that contains a valid database with a local or remote MySQL server instance. The Autogenerate Schema and Write exceptions to event log options can be selected for this web provider.

After setting up the site map provider, a new section is added to the web configuration file.

<siteMap defaultProvider="MySqlSiteMapProvider">

      <providers>

        <remove name="MySqlSiteMapProvider" />

        <add name="MySqlSiteMapProvider" type="MySql.Web.SiteMap.MySqlSiteMapProvider, MySql.Web, Version=8.0.18.0, 
          Culture=neutral, PublicKeyToken=c2222fc22222c44d"
          applicationName="/" description="" connectionStringName="LocalMySqlServer" writeExceptionsToEventLog="False" 
          autogenerateschema="False" enableExpireCallback="False" />

      </providers>

</siteMap>

Click Next to proceed to the web personalization configuration page:

Web Personalization Provider

The web personalization provider is used when a website application needs to store persistent information for the content and layout of the Web Parts pages that are generated by a Web Parts personalization service. This provider should be used along with the membership, roles, and profiles providers. Click Use MySQL to manage my ASP.NET personalization provider to enable this provider page.

The required configuration options: A name for the application and a connection string that contains a valid database with a local or remote MySQL server instance. The Autogenerate Schema and Write exceptions to event log options can be selected for this web provider.

After setting up the web personalization provider, a new section is added to the web configuration file.

<webParts>

      <personalization defaultProvider="MySQLPersonalizationProvider">

        <providers>

          <remove name="MySQLPersonalizationProvider" />

          <add name="MySQLPersonalizationProvider" type="MySql.Web.Personalization.MySqlPersonalizationProvider, 
          MySql.Web, Version=8.0.18.0, Culture=neutral, PublicKeyToken=c2222fc22222c44d" 
          applicationName="/" description="" connectionStringName="LocalMySqlServer" writeExceptionsToEventLog="False" 
          autogenerateschema="False" enableExpireCallback="False" />

        </providers>

      </personalization>

</webParts>

When you have selected the web personalization options, click Finish to write the changes for all web provides to the Web.config file and close the tool.