web.config中的ASP.Net成员资格配置问题 [英] ASP.Net membership configuration in web.config Problem

查看:54
本文介绍了web.config中的ASP.Net成员资格配置问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在VS2010中使用我的ASP.Net项目的成员资格。



首先:我使用aspnet_regsql创建数据库(自定义名称);



秒:在我的web.config中我写道:

I'm trying to use membership in my ASP.Net project in VS2010.

first: I create database with aspnet_regsql (with a custom name);

second: in my web.config I wrote:

<configuration>
	<connectionStrings>
		<add name="MySqlConnection" connectionString="Data Source=(LocalDB)\v11.0;Initial Catalog=Math;Integrated Security=True;User Instance=true;" providerName="System.Data.SqlClient"></add>
	</connectionStrings>
	<system.web>
		<!--<authentication mode="Forms">
			<forms loginUrl="Default.aspx" name=".ASPXFORMSAUTH"/>
		</authentication>-->
		<authorization>
			<deny users="?"/>
		</authorization>
		<membership>
			<providers>
				<add connectionStringName="MySqlConnection" applicationName="MyApplication" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="true" requiresUniqueEmail="true" passwordFormat="Hashed" name="SqlProvider" type="System.Web.Security.SqlMembershipProvider"/>
			</providers>
		</membership>
		<compilation debug="true"/></system.web>
</configuration>







第三:在提供部分的管理工具中,我收到此错误:



无法建立与数据库的连接。如果尚未创建SQL Server数据库,请退出网站管理工具,使用aspnet_regsql命令行实用程序创建和配置数据库,然后返回此工具以设置提供程序



问题在哪里?




Third: in Administrative tools in Provide section, I got this error:

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

where is the problem?

推荐答案

修改你的web.config代码,如下所示:



Modify your web.config code as shown below:

<configuration>
    <connectionstrings>
      <add name="MySqlConnection" providername="System.Data.SqlClient">
      connectionString="Server=mssql.world19.server-world.net;Database=micro ;Uid=x123; Pwd=y123" />
    </add></connectionstrings>
    <system.web>
      



      

      <!-- AUTHENTICATION -->
      <authentication mode="Forms">
       <forms loginurl="login.aspx" name=".ASPXFORMSAUTH" />
      </authentication>
      <!-- AUTHORIZATIONN -->
      <authorization>
        <deny users="?" />
      </authorization>
      

     



      <membership defaultprovider="AspNetSqlMembershipProvider" userisonlinetimewindow="15">
        <providers>
          <clear />
          <add name="AspNetSqlMembershipProvider">
              type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
              connectionStringName="MySqlConnection"
              enablePasswordRetrieval="false"
              enablePasswordReset="true"
              requiresQuestionAndAnswer="true"
              applicationName="/"
              requiresUniqueEmail="false"
              passwordFormat="Hashed"
              maxInvalidPasswordAttempts="5"
              minRequiredPasswordLength="7"
              minRequiredNonalphanumericCharacters="1"
              passwordAttemptWindow="10"
              passwordStrengthRegularExpression="" />
        </add></providers>
      </membership>


      <profile>
        <providers>
          <clear />
          <add name="AspNetSqlProfileProvider" connectionstringname="MySqlConnection" applicationname="/">
              type="System.Web.Profile.SqlProfileProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
        </add></providers>
      </profile>


      <rolemanager>
        <providers>
          <clear />
          <add name="AspNetSqlRoleProvider" connectionstringname="MySqlConnection" applicationname="/">
              type="System.Web.Security.SqlRoleProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
          <add name="AspNetWindowsTokenRoleProvider" applicationname="/">
              type="System.Web.Security.WindowsTokenRoleProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
        </add></add></providers>
      </rolemanager>
      

      

      

      

      

      

    </system.web>
  </configuration>


这篇关于web.config中的ASP.Net成员资格配置问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆