2012-10-18 15 views
3

將ASP.NET的默認成員資格連接字符串更改爲遠程連接字符串時出現問題。這是我想使用的連接字符串:成員遠程連接字符串在SQL Server Management Studio中工作,但不在ASP.NET中(錯誤26)

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/

回答

0

你需要改變這樣的:

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

我也注意到,您的連接字符串Data Source=xxxxxxx.com,我假設你只是阻止了張貼,但它真的在.com結束?你確定完全合格的.com地址可以從你的網絡服務器解決嗎?

+0

該地址確實以.com結尾,我確定它正在工作,因爲我使用Sql Management Studio對其進行了測試 – Phoenix

+0

謝謝,此工作正常,現在我可以使用成員身份功能沒有問題,但還有一個問題:當我轉到Asp.Net Web站點管理工具並嘗試測試它失敗的AspNetSqlProvider,並且出現以下錯誤:無法建立到數據庫的連接。 如果尚未創建SQL Server數據庫,請退出Web站點管理工具,使用aspnet_regsql命令行實用程序創建和配置數據庫,然後返回到此工具以設置提供程序。 – Phoenix

+0

...也是的 - 註冊和登錄DO的工作,所以我不知道爲什麼這個錯誤... – Phoenix

0

我想你應該刪除「Integrated Security = True」,我不認爲共享主機會使用你的windows帳戶和密碼。

+0

感謝您的回覆但我得到了同樣的錯誤。 – Phoenix

相關問題