gpt4 book ai didi

c# - 成员资格远程连接字符串在 SQL Server Management Studio 中有效但在 ASP.NET 中无效(错误 26)

转载 作者:行者123 更新时间:2023-11-30 18:37:17 25 4
gpt4 key购买 nike

我在将 ASP.NET 的默认成员连接字符串更改为远程连接字符串时遇到问题。这是我尝试使用的连接字符串:

Data Source=myserver.com;Integrated Security=True;Initial Catalog=database_name;User ID=username;Password=password

数据库托管在共享主机上,可以通过 SQL Server Management Studio 访问,我还使用记事本方法等测试了完全相同的连接字符串...

所以,我几乎可以肯定问题不是我的连接字符串,而是 web.config 中的其他内容。这是 web.config 文件:

http://pastebin.com/JsATXqW7 .

<?xml version="1.0" encoding="utf-8"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=152368
-->
<configuration>
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
<add key="webpages:Version" value="1.0.0.0" />
<add key="ClientValidationEnabled" value="true" />
<add key="UnobtrusiveJavaScriptEnabled" value="true" />
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.5" />
<authentication mode="Forms">
<forms loginUrl="~/Account/LogOn" timeout="2880" />
</authentication>
<pages>
<namespaces>
<add namespace="System.Web.Helpers" />
<add namespace="System.Web.Mvc" />
<add namespace="System.Web.Mvc.Ajax" />
<add namespace="System.Web.Mvc.Html" />
<add namespace="System.Web.Routing" />
<add namespace="System.Web.WebPages" />
</namespaces>
</pages>
<httpRuntime targetFramework="4.5" requestValidationMode="4.5" encoderType="System.Web.Security.AntiXss.AntiXssEncoder, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<machineKey compatibilityMode="Framework45" />
<profile defaultProvider="DefaultProfileProvider">
<providers>
<add name="DefaultProfileProvider" type="System.Web.Providers.DefaultProfileProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection" applicationName="/" />
</providers>
</profile>
<membership>
<providers>
<add connectionStringName="RemoteDB" enablePasswordRetrieval="false"
enablePasswordReset="true" requiresQuestionAndAnswer="false"
requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6"
minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10"
applicationName="/" name="DefaultMembershipProvider" type="System.Web.Providers.DefaultMembershipProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
</providers>
</membership>
<roleManager>
<providers>
<add connectionStringName="RemoteDB" applicationName="/"
name="DefaultRoleProvider" type="System.Web.Providers.DefaultRoleProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
</providers>
</roleManager>
<sessionState mode="InProc" customProvider="DefaultSessionProvider">
<providers>
<add name="DefaultSessionProvider" type="System.Web.Providers.DefaultSessionStateProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="RemoteDB" />
</providers>
</sessionState>
</system.web>
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
</system.webServer>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="3.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
<parameters>
<parameter value="v11.0" />
</parameters>
</defaultConnectionFactory>
</entityFramework>
<connectionStrings>
<add name="DefaultConnection" providerName="System.Data.SqlClient" connectionString="Data Source=(LocalDb)\v11.0;Initial Catalog=aspnet-SkypeSpammerWeb-20121018205959;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnet-SkypeSpammerWeb-20121018205959.mdf" />
<add name="RemoteDB" providerName="System.Data.SqlClient" connectionString="Data Source=xxxxxxx.com;Integrated Security=True;Initial Catalog=xxxxxx;User ID=xxxxxx;Password=xxxxxxxx"/>
</connectionStrings>
</configuration>

这是我收到的错误的屏幕截图:

http://postimage.org/image/3vd3dbahf/

最佳答案

你需要改成这样:

<membership defaultProvider="DefaultMembershipProvider">
<providers>
<clear/>
<add ...

我还注意到您的连接字符串有 Data Source=xxxxxxx.com,我假设您只是为了发布而阻止了它,但它真的以 .com 结尾吗?您确定完全限定的 .com 地址可以从您的 Web 服务器解析吗?

关于c# - 成员资格远程连接字符串在 SQL Server Management Studio 中有效但在 ASP.NET 中无效(错误 26),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12964313/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com