1

我是 ASP.net 的新手,只是遵循教程。这个特殊问题让我非常头疼,我在 VS 2010 中开发了一个网站,使用 Asp.Net Login Controls 提供的 ASPNETDB SQL 服务器数据库来创建用户和角色。还添加了一些表,在我完成后使用“发布到提供者”功能生成脚本 (ASPNETDB.MDF.sql)。我使用此脚本生成数据库和表 -Sql Server 2008 R2 management Studio,并像这样修改了 web.config -

<!--Connection String-->
                <connectionStrings>
        <remove name="LocalSqlServer" />
        <add name="LocalSqlServer"  connectionString="Server=AkumJamir-PC\SQLEXPRESS;Initial Catalog=ASPNETDB;Integrated Security=true" providerName="System.Data.SqlClient" />
                <add name="con" connectionString="Server=AkumJamir-PC\SQLEXPRESS;Initial Catalog=ASPNETDB;Integrated Security=True"/>
                <add name="ConnectionString" connectionString="Server=AkumJamir-PC\SQLEXPRESS;Initial Catalog=ASPNETDB;Integrated Security=True" providerName="System.Data.SqlClient" />
</connectionStrings>
<roleManager enabled="true">
        <providers>
            <remove name="AspNetSqlRoleProvider"/>
            <add connectionStringName="ConnectionString" applicationName="/"
                 name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider,System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
            <remove name="AspNetWindowsTokenProvider"/>
        </providers>
    </roleManager>

<membership>
        <providers>
            <remove name="AspNetMembershipProvider"/>
            <add connectionStringName="ConnectionString" enablePasswordRetrieval="true" enablePasswordReset="true" requiresQuestionAndAnswer="true" applicationName="/" requiresUniqueEmail="false" passwordFormat="Hashed" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="7" minRequiredNonalphaNumericCharacters="1" passwordAttemptWindow="5" passwordStrengthRegularExpression="" name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider,System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
        </providers>
    </membership>   
    <webParts>
        <personalization defaultProvider="AspNetSqlPersonalizationProvider">
            <providers>
                <remove name="AspNetSqlPersonalizationProvider"/>
                <add name="AspNetSqlPersonalizationProvider" type="System.Web.UI.WebControls.Webparts.SqlPersonalizationProvider"
                 connectionStringname="ConnectionString" applicationName="/"/>
            </providers>
        </personalization>
    </webParts>

现在的问题是在我的开发机器上工作但在我们的登台服务器上,每当我尝试浏览到某些页面时,它都无法连接到数据库,在这些页面中我有一些数据要从数据库中显示,登录页面也不起作用。connectionString 看起来像这样在服务器中:

<!--Connection String-->
                <connectionStrings>
        <remove name="LocalSqlServer" />
        <add name="LocalSqlServer"  connectionString="Driver={SQL Native Client};Server=WIN-K16NMM4128C;Initial Catalog=ASPNETDB;Integrated Security=true" providerName="System.Data.SqlClient" />
                <add name="con" connectionString="Server=WIN-K16NMM4128C;Initial Catalog=ASPNETDB;Integrated Security=True"/>
                <add name="ConnectionString" connectionString="Data Source=WIN-K16NMM4128C\SqlServer2008;Initial Catalog=ASPNETDB;Integrated Security=True" providerName="System.Data.SqlClient" />
</connectionStrings>

我正在吃掉我的脑筋,我已经浏览了已经涵盖的主题,,,,感谢您的任何建议...

4

2 回答 2

2

我面临着同样的问题。我刚刚在 IIS 管理器中启用了 ASP/Authentication,并且设置了 Basic Authentication=true。它现在正在工作。

于 2012-12-19T03:56:19.577 回答
1

您在连接字符串中使用集成安全性。将其配置为使用 sql 身份验证。像这样的东西:

Data Source=myServerAddress;Initial Catalog=myDataBase;User Id=myUsername;Password=myPassword;
于 2012-07-18T10:24:41.553 回答