2016-03-19 134 views
1

我希望有人能夠在這裏向正確的方向推動我。我正在使用Visual Studios 2015社區版。asp.net用戶正在登錄,但正在返回登錄頁面

我的Login.aspx頁面在帳戶文件夾中。帳戶文件夾中的我的web.config文件如下所示;

<?xml version="1.0"?> 
<configuration> 

<location path="Manage.aspx"> 
<system.web> 
    <authorization> 
    <deny users="?"/> 
    </authorization> 
</system.web> 
</location> 

<location path="Home.aspx"> 
<system.web> 
    <authorization> 
    <deny users="?"/> 
    </authorization> 
</system.web> 
</location> 
<location path="Home"> 
<system.web> 
    <authorization> 
    <deny users="?"/> 
    </authorization> 
</system.web> 
</location> 

</configuration> 

我在Account文件夾中也有一個Home.aspx文件。當我直接導航到Home.aspx文件時,我將按照預期重定向到登錄頁面。如果我登錄,我可以看到我登錄,因爲Site.Master模板邏輯歡迎我。但是,我沒有重定向到Home.aspx網站,而是仍然在登錄頁面。

我可以看到url字符串中的returnurl值似乎試圖導航到正確的頁面。

http://localhost:63960/Account/Login?ReturnUrl=%2fAccount%2fHome.aspx 

但是,我仍然在登錄頁面。

我在根文件夾中的web.config如下所示;

<?xml version="1.0" encoding="utf-8"?> 

<configuration> 
<configSections> 

</configSections> 
<connectionStrings> 
<add name="EventDBContext" connectionString="Data Source=.;Initial Catalog=SampleDB;Integrated Security=True;" providerName="System.Data.SqlClient"/> 
<add name="ApplicationServices" connectionString="Data Source=.;Initial Catalog=SampleDB;Integrated Security=True;" providerName="System.Data.SqlClient" /> 
</connectionStrings> 
<system.web> 
<authentication mode="Forms"> 
    <forms loginUrl="~/Account/Login.aspx" timeout="2880" /> 
</authentication> 
<compilation debug="true" targetFramework="4.5.2" /> 
<httpRuntime targetFramework="4.5.2" /> 
<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" /> 
    </controls> 
    </pages> 
    <membership> 
    <providers> 
    <clear /> 
    <add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="ApplicationServices" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="/" /> 
    </providers> 
</membership> 
<profile> 
    <providers> 
    <clear /> 
    <add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="ApplicationServices" applicationName="/" /> 
    </providers> 
    </profile> 
    <roleManager enabled="true"> 

    <providers> 
    <clear /> 
    <add name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider" connectionStringName="ApplicationServices" applicationName="/" /> 
    <add name="AspNetWindowsTokenRoleProvider" type="System.Web.Security.WindowsTokenRoleProvider" applicationName="/" /> 

    </providers> 
    </roleManager> 

    <sessionState mode="InProc" customProvider="DefaultSessionProvider"> 
    <providers> 
    <add name="DefaultSessionProvider" type="System.Web.Providers.DefaultSessionStateProvider, System.Web.Providers, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31xxxxxxxe35" connectionStringName="DefaultConnection" /> 
    </providers> 
    </sessionState> 
    <httpModules> 
    <add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web" /> 
    </httpModules> 
    </system.web> 
    <system.webServer> 
    <modules> 

    <remove name="ApplicationInsightsWebTracking" /> 
    <add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web" preCondition="managedHandler" /> 
    </modules> 
    <validation validateIntegratedModeConfiguration="false" /> 
</system.webServer> 
<runtime> 
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> 
    <dependentAssembly> 
    <assemblyIdentity name="Newtonsoft.Json" culture="neutral" publicKeyToken="30xxxxxxed" /> 
    <bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" /> 
    </dependentAssembly> 
    <dependentAssembly> 
    <assemblyIdentity name="WebGrease" culture="neutral" publicKeyToken="31xxxxxxxe35" /> 
    <bindingRedirect oldVersion="0.0.0.0-1.5.2.14234" newVersion="1.5.2.14234" /> 
    </dependentAssembly> 
    <dependentAssembly> 
    <assemblyIdentity name="EntityFramework" publicKeyToken="b77xxxxx89" /> 
    <bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" /> 
    </dependentAssembly> 
    <dependentAssembly> 
    <assemblyIdentity name="Microsoft.Owin" culture="neutral" publicKeyToken="31xxxxxxxe35" /> 
    <bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.0" /> 
    </dependentAssembly> 
    <dependentAssembly> 
    <assemblyIdentity name="Microsoft.Owin.Security.OAuth" culture="neutral" publicKeyToken="31xxxxxxxe35" /> 
    <bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.0" /> 
    </dependentAssembly> 
    <dependentAssembly> 
    <assemblyIdentity name="Microsoft.Owin.Security.Cookies" culture="neutral" publicKeyToken="31xxxxxxxe35" /> 
    <bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.0" /> 
    </dependentAssembly> 
    <dependentAssembly> 
    <assemblyIdentity name="Microsoft.Owin.Security" culture="neutral" publicKeyToken="31xxxxxxxe35" /> 
    <bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.0" /> 
    </dependentAssembly> 
    </assemblyBinding> 
</runtime> 
<system.codedom> 
<compilers> 
    <compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31xxxxxxxe35" warningLevel="4" compilerOptions="/langversion:6 /nowarn:1659;1699;1701" /> 
    <compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31xxxxxxxe35" warningLevel="4" compilerOptions="/langversion:14 /nowarn:41008 /define:_MYTYPE=\&quot;Web\&quot; /optionInfer+" /> 
</compilers> 
</system.codedom> 
</configuration> 

任何指導將不勝感激。

回答

0

我想通了我的問題。我將之前的表單身份驗證方法與asp.net Identity方法混合使用。

我還沒有將所有內容都轉換爲Identity方法,並且所有工作都正常。

相關問題