我有一個asp.net網站。我使用由模板和嚮導生成的asp.net登錄控件。我的表,如AspNetUsers和AspNetRoles與我的數據在同一個分貝。 當我運行我的網站對本地sqlserver數據庫時,我可以使用我的登錄控件登錄,並且一切正常。當我將我的網站移動到GoDaddy(我也在smarterAsp.net上嘗試了同樣的問題)時,我的登錄控件有時會起作用。其他時候,它只是忽略我,並帶我回到默認頁面,沒有錯誤信息。如果我重置應用程序池或更改web.config(似乎重置應用程序池),我可以再次登錄幾次。在IE瀏覽器中,它比Chrome要糟糕得多。在IE中我很少登錄。asp.net登錄控件總是與本地sqlserver一起工作,但只能間歇地在託管服務器上
爲了解決我的數據庫連接問題,我添加到了我的一個頁面,這樣我就可以在不登錄的情況下訪問它。在我訪問訪問數據庫的頁面後,如果我進入登錄頁面,我可以登錄。在我看來,我的登錄控件不被允許訪問數據庫,但我的頁面上的列表視圖控件是,然後一旦連接被sqlDataSource打開,然後登錄控件可以進行身份驗證。我已經浪費了一個星期!幫幫我! 我使用相同的連接字符串SQLDataSources以及aspnet身份驗證。 這是我的web.config。這可能有點混亂,因爲我一直在嘗試各種各樣的事情。我只使用「LocalSqlServer」連接字符串。
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<connectionStrings>
<remove name="LocalSqlServer"/>
<add name="LocalSqlServer" connectionString="Data Source=ServerIP;Initial Catalog=Aveida;Integrated Security=False;User Id=XXXXX; Password=XXXXXX" providerName="System.Data.SqlClient" />
<remove name = "DefaultConnection"/>
<add name="DefaultConnection" connectionString="Data Source=ServerIP;Initial Catalog=Aveida;Integrated Security=False;User Id=XXXXX; Password=XXXXXX" providerName="System.Data.SqlClient" />
</connectionStrings>
<system.web>
<globalization uiCulture="en-US" culture="he-IL" />
<customErrors mode="Off" />
<trust level="Full" />
<authentication mode="None" />
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5" />
<pages>
<namespaces>
<add namespace="System.Web.Optimization" />
<add namespace="Microsoft.AspNet.Identity" />
</namespaces>
<controls>
<add assembly="Microsoft.AspNet.Web.Optimization.WebForms" namespace="Microsoft.AspNet.Web.Optimization.WebForms" tagPrefix="webopt" />
<add tagPrefix="ajaxToolkit" assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" />
</controls>
</pages>
<membership>
<providers>
<!--
ASP.NET Membership is disabled in this template. Please visit the following link http://go.microsoft.com/fwlink/?LinkId=301889 to learn about the ASP.NET Membership support in this template
-->
<clear />
</providers>
</membership>
<profile>
<providers>
<!--
ASP.NET Membership Profile is disabled in this template. Please visit the following link http://go.microsoft.com/fwlink/?LinkId=301889 to learn about the ASP.NET Membership support in this template
-->
<clear />
</providers>
</profile>
<roleManager>
<!--
ASP.NET Membership Role is disabled in this template. Please visit the following link http://go.microsoft.com/fwlink/?LinkId=301889 to learn about the ASP.NET Membership support in this template
-->
<providers>
<clear />
</providers>
</roleManager>
<!--
If you are deploying to a cloud environment that has multiple web server instances,
you should change session state mode from "InProc" to "Custom". In addition,
change the connection string named "DefaultConnection" to connect to an instance
of SQL Server (including SQL Azure and SQL Compact) instead of to SQL Server Express.
-->
<sessionState mode="Custom" customProvider="DefaultSessionProvider">
<providers>
<add name="DefaultSessionProvider" type="System.Web.Providers.DefaultSessionStateProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="LocalSqlServer" />
</providers>
</sessionState>
</system.web>
<system.webServer>
<modules>
<remove name="FormsAuthenticationModule" />
</modules>
</system.webServer>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="WebGrease" culture="neutral" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="0.0.0.0-1.5.2.14234" newVersion="1.5.2.14234" />
</dependentAssembly>
</assemblyBinding>
</runtime>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</providers>
</entityFramework>
<location path="SearchLost.aspx">
<system.web>
<authorization>
<allow roles="member,manager" />
<deny users="*" />
</authorization>
</system.web>
</location>
<location path="Account/Register.aspx">
<system.web>
<authorization>
<allow roles="manager" />
<deny users="*" />
</authorization>
</system.web>
</location>
</configuration>
我想我解決了這個問題。 (無法構成爲幾個小時的答案) 我改變 <的sessionState模式= 「自定義」 customProvider = 「DefaultSessionProvider」> <添加名稱= 「DefaultSessionProvider」 類型=「System.Web.Providers .DefaultSessionStateProvider,System.Web.Providers,版本= 1.0.0.0,文化=中性公鑰= 31bf3856ad364e35" 的connectionStringName = 「LocalSqlServer」 這個/> 只是 <的sessionState模式= 「是InProc」> 我擺脫了customProvider(不知道我從哪裏開始),它似乎工作。 –
KellyK