簡體   English   中英

asp.net用戶登錄但返回登錄頁面

[英]asp.net user being logged in but being returned to login page

我希望有人可以在這里向正確的方向發展。 我正在使用Visual Studios 2015社區版。

我的Login.aspx頁面位於Account文件夾中。 我在Account文件夾中的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>

任何指導將不勝感激。

我想出了我的問題。 我將以前的表單身份驗證方法與asp.net身份方法混合在一起。

我尚未將所有內容都轉換為“身份”方法,並且一切正常。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM