Azure Active Directory无法正常工作(删除Cookie后)

时间:2017-07-11 12:57:44

标签: asp.net-mvc azure azure-active-directory azure-app-service-plans

我创建了一个MVC应用程序,并与Active Directory一起托管在Azure App中。 这里的问题是当使用Active Directory单击“提交”按钮(登录模块)时,它有时会起作用,有时不起作用

它在某种意义上不起作用=> 加载时需要花费太多时间才能获得重播网址 enter image description here

并导致错误请求!

enter image description here

重新调整问题的步骤:

  1. 当我尝试删除浏览器中的cookie时。这不起作用。(长时间加载并导致错误请求)m

  2. 当我尝试在多个浏览器中打开时

  3. 这里我的问题的原因是什么?

    (P.s:我使用Azure Sql Server作为数据库连接字符串)

    先谢谢,
    Jayendran

    更新1

    的Web.config

       <?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=301880
      -->
    <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=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
      </configSections>
      <connectionStrings>
        <add name="DefaultConnection" connectionString="Server = tcp:myazuresql.database.windows.net,1433; Initial Catalog = database; Persist Security Info = False; User ID = username; Password = mypassW@Azure; MultipleActiveResultSets = False; Encrypt = True; TrustServerCertificate = False; Connection Timeout = 30;" providerName="System.Data.SqlClient" />
      </connectionStrings>
      <appSettings>
        <add key="webpages:Version" value="3.0.0.0" />
        <add key="webpages:Enabled" value="false" />
        <add key="ClientValidationEnabled" value="true" />
        <add key="UnobtrusiveJavaScriptEnabled" value="true" />
        <add key="ida:ClientId" value="to be filled" />
        <add key="ida:AADInstance" value="https://login.microsoftonline.com/" />
        <add key="ida:ClientSecret" value="to be filled" />
        <add key="ida:Domain" value="domain.com" />
        <add key="ida:TenantId" value="to be filled" />
        <add key="ida:PostLogoutRedirectUri" value="https://ww.mydomain.com/" />
      </appSettings>
      <system.web>
        <customErrors mode="Off" />
        <compilation targetFramework="4.5" />
        <httpRuntime targetFramework="4.5" />
        <httpRuntime maxRequestLength="10000"/>
      </system.web>
      <runtime>
        <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
          <dependentAssembly>
            <assemblyIdentity name="Newtonsoft.Json" culture="neutral" publicKeyToken="30ad4fe6b2a6aeed" />
            <bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
          </dependentAssembly>
          <dependentAssembly>
            <assemblyIdentity name="System.Web.Optimization" publicKeyToken="31bf3856ad364e35" />
            <bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="1.1.0.0" />
          </dependentAssembly>
          <dependentAssembly>
            <assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" />
            <bindingRedirect oldVersion="0.0.0.0-1.5.2.14234" newVersion="1.5.2.14234" />
          </dependentAssembly>
          <dependentAssembly>
            <assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
            <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
          </dependentAssembly>
          <dependentAssembly>
            <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
            <bindingRedirect oldVersion="1.0.0.0-5.2.3.0" newVersion="5.2.3.0" />
          </dependentAssembly>
          <dependentAssembly>
            <assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
            <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
          </dependentAssembly>
          <dependentAssembly>
            <assemblyIdentity name="System.Spatial" publicKeyToken="31bf3856ad364e35" culture="neutral" />
            <bindingRedirect oldVersion="0.0.0.0-5.6.4.0" newVersion="5.6.4.0" />
          </dependentAssembly>
          <dependentAssembly>
            <assemblyIdentity name="Microsoft.Data.Services.Client" publicKeyToken="31bf3856ad364e35" culture="neutral" />
            <bindingRedirect oldVersion="0.0.0.0-5.8.1.0" newVersion="5.8.1.0" />
          </dependentAssembly>
          <dependentAssembly>
            <assemblyIdentity name="Microsoft.Data.Edm" publicKeyToken="31bf3856ad364e35" culture="neutral" />
            <bindingRedirect oldVersion="0.0.0.0-5.8.1.0" newVersion="5.8.1.0" />
          </dependentAssembly>
          <dependentAssembly>
            <assemblyIdentity name="Microsoft.Data.OData" publicKeyToken="31bf3856ad364e35" culture="neutral" />
            <bindingRedirect oldVersion="0.0.0.0-5.8.1.0" newVersion="5.8.1.0" />
          </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>
      <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=31bf3856ad364e35" 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=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:14 /nowarn:41008 /define:_MYTYPE=\&quot;Web\&quot; /optionInfer+" />
        </compilers>
      </system.codedom>
      </configuration>
    

    现在响应标头长度为75 enter image description here

    更新2

    我刚刚发现为什么页面在chrome

    的开发者工具的帮助下加载了这么多时间

    在登录页面期间:请求标题显示 显示临时标题

    enter image description here

    此网址会将我的登录页面折叠为连续运行。我还检查了复制此URL并将其粘贴到单独的标签中。它花费了太多时间并且Req标题结束时间过长

2 个答案:

答案 0 :(得分:0)

根据错误消息,您的请求标头很长。 default size为4096 KB(4 MB),要更改我们可以配置的默认大小,如下所示:

<system.web>
        <httpRuntime maxRequestLength="10000"/>
</system.web>

答案 1 :(得分:0)

这是Katana中的一个已知错误,其中Katana cookie管理器和ASP .NET cookie管理器冲突并覆盖彼此的cookie

我刚刚使用以下答案修复

Second sign-in causes infinite redirect loop after the first successful login MVC .NET 5 OWIN ADAL OpenIDConnect