【问题标题】:Azure Active Directory not Working (After deletion of Cookies)Azure Active Directory 不工作(删除 Cookie 后)
【发布时间】:2017-12-15 13:26:12
【问题描述】:

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

它在某种意义上不起作用=> 加载需要太多时间才能获得重播 URL 像这样

结果是错误的请求!

重新处理我的问题的步骤:

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

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

我的问题的原因是什么?

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

提前致谢,
贾延德兰

更新 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

更新 2

我刚刚在 chrome 的开发者工具的帮助下找到了为什么页面加载时间如此之长

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

此 URL 使我的登录页面折叠起来以连续运行。我还检查了复制此 URL 并将其粘贴到单独的选项卡中。这需要太多时间并且以 Req 标头太长结束

【问题讨论】:

  • 您将在此处添加一些代码。我怀疑任何人都可以仅根据此描述提供帮助。
  • @juunas 请参阅上面的更新代码。 Web.Config 文件。我想这就够了

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


【解决方案1】:

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

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

【讨论】:

  • 不,当我添加上面的配置时它不起作用我得到类似 页面无法显示,因为发生内部服务器错误。 它甚至没有显示登录页面:(
  • 您介意更新您修改的配置吗?另外,我建议你也使用 Fiddler 或 Chrome 的开发者工具检查请求,看看哪些 headers 太长。
  • 请看上面的(更新2)。正如你提到的,我还验证了 chrome 中的开发工具看起来没有 * 标题太长 * 错误。它产生了一个新的错误,就像我上面提到的那样还添加了图像
  • 我刚刚找到了header过长运行时间过长的原因。请看上面的Updated 2。我认为这个URL是造成Request header过长的原因!
  • 根据上图,似乎是正确的。还有其他标题吗?
【解决方案2】:

这是 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

【讨论】:

    猜你喜欢
    • 2017-12-11
    • 2014-03-18
    • 1970-01-01
    • 1970-01-01
    • 2016-01-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多