0

I've created a MVC Application and hosted in Azure App along with Active Directory. The problem here is when clicking the Submit Button (login module) with Active Directory ,it works for sometimes and not after sometimes

It not working in the sense=> It took too much time for loading to get the replay URL Like thisenter image description here

And result with the Bad Request !

enter image description here

Steps to re-pro my Issue:

  1. When i tried to delete the cookies in my browser.This will not be work.(Long time Loading and result into Bad Request)m

  2. When i tried to open in multiple browser

What will be the Cause for my Problem here ?

(P.s : I used Azure Sql Server for the Database Connection string)

Thanks in Advance,
Jayendran

UPDATED 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>

Now the response header length is 75enter image description here

UPDATED 2

I just found why the Page loading so much time with the help of developer tool in chrome

During the login Page : The Request Header says Provisional headers are shown

enter image description here

This URL makes collapse my Login Page to run Continuously. I also checked copy this URL and paste it in separate tab.It takes too much time and ended with Req header too long

Bugs
  • 4,491
  • 9
  • 32
  • 41
Jayendran
  • 9,638
  • 8
  • 60
  • 103

2 Answers2

0

Based on the error message, your request header is to long. The default size is 4096 KB (4 MB), to change the default size we can config like below:

<system.web>
        <httpRuntime maxRequestLength="10000"/>
</system.web>
Fei Xue
  • 14,369
  • 1
  • 19
  • 27
  • No,it's not working when i added the above config i get the error like *The page cannot be displayed because an internal server error has occurred.* It not even displaying the login page :( – Jayendran Jul 12 '17 at 05:41
  • Would you mind updating the config you have modified? In-addition, I suggest that you also check the request using Fiddler or Developer Tools of Chrome to see which headers is too long. – Fei Xue Jul 12 '17 at 05:50
  • Please see the( Updated 2 ) above. As you mentioned i also verified the Developer Tools in chrome Looks like there is no * too long headers * Error .It produced a new error like i mentioned above Also added the Image too – Jayendran Jul 12 '17 at 06:06
  • I just found the cause of the header too long and long running scenario.Please see the Updated 2 above .I think this URL is causing the Request header too long ! – Jayendran Jul 12 '17 at 06:32
  • Based on the above figure, it seems to be correct. Is there any other headers? – Fei Xue Jul 12 '17 at 08:03
  • No only the above header Updated 2 causing the issue.Some times it works .But after deleting the cookies.The request header gets increased in length automatically ! the leads to be loading much time – Jayendran Jul 12 '17 at 08:06
  • After deleting the cookies, the web APP will redirect users to login. And the request seems also to be correct. I also testing this issue using [this code sample](https://github.com/Azure-Samples/active-directory-dotnet-webapp-openidconnect), however failed. And when you refer loading much time, which request did you mean? The login request or the web app page request? – Fei Xue Jul 12 '17 at 08:16
  • I think this will belongs login request.Since i used Active Directory for my login purpose.The header which structs too much time was belong to the login url *https://login.microsoftonline.com.....blabla* Web app page request can be seen.But the Login Request could able to get the response timely. – Jayendran Jul 12 '17 at 08:20
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/148983/discussion-between-jayendran-rosh-and-fei-xue-msft). – Jayendran Jul 12 '17 at 09:01
  • The request headers are constructed by the OWIN component. And since the issue is not able reproduced, can you reproduce this issue using the code sample above? So that we can narrow down whether this issue caused by code or environment. – Fei Xue Jul 12 '17 at 09:22
  • Code Sample Above in the mean , You Answer ? ? Adding ,When i tired with my local maching (without AD) there is no issue.When i tried to implement the AD. I experiencing this issues – Jayendran Jul 13 '17 at 03:36
  • The code sampe is in the comment above, you can check it from [this link](https://github.com/Azure-Samples/active-directory-dotnet-webapp-openidconnect). – Fei Xue Jul 13 '17 at 08:43
  • Just now I've solved my problem It's known bug in Katana .Now it's working fine. Appreciate your response and feedback for me for the past couple of days – Jayendran Jul 14 '17 at 06:20
0

It's a known bug in Katana where the Katana cookie manager and the ASP .NET cookie manager clash and overwrite each other's cookies

I've just fixed using the below Answer

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

Jayendran
  • 9,638
  • 8
  • 60
  • 103