IIS Deployed ASP.NET Core application giving intermittent 431 Request headers too long error












0















I am working on an ASP.NET Core application which consumes a GraphQL endpoint via RestSharp to retrieve the data. This is an intranet type application, deployed on a Windows 2016 IIS Server and we are utilizing Windows Authentication. The problem we are encountering is that a certain user, who belongs to a large number of active directory groups is getting intermittent 431 Request headers too long errors.



I have attempted the following:





  1. I am setting the IISDefaults in the startup.cs for both the application and service:



    services.AddAuthentication(IISDefaults.AuthenticationScheme);



  2. I am passing UseDefaultCredentials in the RestRequest



    var client = new RestClient(endpoint);
    var request = new RestRequest(Method.POST);
    request.UseDefaultCredentials = true;
    request.AddHeader("content-type", "application/json");
    request.AddParameter("application/json", data, ParameterType.RequestBody);
    IRestResponse response = client.Execute(request);
    return response.Content;


  3. Set the registry entries for MaxFieldLength and MaxRequestBytes to the max allowed.



Log from stdout:




info: Microsoft.AspNetCore.Server.Kestrel[17]
Connection id "0HLIABLA41UKH" bad request data: "Request headers too long."
Microsoft.AspNetCore.Server.Kestrel.Core.BadHttpRequestException: Request headers too long. at Microsoft.AspNetCore.Server.Kestrel.Core.BadHttpRequestException.Throw(RequestRejectionReason reason) at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.Http1Connection.TakeMessageHeaders(ReadOnlySequence1 buffer, SequencePosition& consumed, SequencePosition& examined) at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.Http1Connection.ParseRequest(ReadOnlySequence1 buffer, SequencePosition& consumed, SequencePosition& examined) at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.Http1Connection.TryParseRequest(ReadResult result, Boolean& endConnection) at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.ProcessRequests[TContext](IHttpApplication1 application) at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.ProcessRequestsAsync[TContext](IHttpApplication1 application)
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[1]











share|improve this question

























  • The user in question is a manager and member of 500+ Active Directory Groups.

    – Jonas Wik
    Nov 15 '18 at 16:12
















0















I am working on an ASP.NET Core application which consumes a GraphQL endpoint via RestSharp to retrieve the data. This is an intranet type application, deployed on a Windows 2016 IIS Server and we are utilizing Windows Authentication. The problem we are encountering is that a certain user, who belongs to a large number of active directory groups is getting intermittent 431 Request headers too long errors.



I have attempted the following:





  1. I am setting the IISDefaults in the startup.cs for both the application and service:



    services.AddAuthentication(IISDefaults.AuthenticationScheme);



  2. I am passing UseDefaultCredentials in the RestRequest



    var client = new RestClient(endpoint);
    var request = new RestRequest(Method.POST);
    request.UseDefaultCredentials = true;
    request.AddHeader("content-type", "application/json");
    request.AddParameter("application/json", data, ParameterType.RequestBody);
    IRestResponse response = client.Execute(request);
    return response.Content;


  3. Set the registry entries for MaxFieldLength and MaxRequestBytes to the max allowed.



Log from stdout:




info: Microsoft.AspNetCore.Server.Kestrel[17]
Connection id "0HLIABLA41UKH" bad request data: "Request headers too long."
Microsoft.AspNetCore.Server.Kestrel.Core.BadHttpRequestException: Request headers too long. at Microsoft.AspNetCore.Server.Kestrel.Core.BadHttpRequestException.Throw(RequestRejectionReason reason) at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.Http1Connection.TakeMessageHeaders(ReadOnlySequence1 buffer, SequencePosition& consumed, SequencePosition& examined) at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.Http1Connection.ParseRequest(ReadOnlySequence1 buffer, SequencePosition& consumed, SequencePosition& examined) at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.Http1Connection.TryParseRequest(ReadResult result, Boolean& endConnection) at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.ProcessRequests[TContext](IHttpApplication1 application) at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.ProcessRequestsAsync[TContext](IHttpApplication1 application)
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[1]











share|improve this question

























  • The user in question is a manager and member of 500+ Active Directory Groups.

    – Jonas Wik
    Nov 15 '18 at 16:12














0












0








0








I am working on an ASP.NET Core application which consumes a GraphQL endpoint via RestSharp to retrieve the data. This is an intranet type application, deployed on a Windows 2016 IIS Server and we are utilizing Windows Authentication. The problem we are encountering is that a certain user, who belongs to a large number of active directory groups is getting intermittent 431 Request headers too long errors.



I have attempted the following:





  1. I am setting the IISDefaults in the startup.cs for both the application and service:



    services.AddAuthentication(IISDefaults.AuthenticationScheme);



  2. I am passing UseDefaultCredentials in the RestRequest



    var client = new RestClient(endpoint);
    var request = new RestRequest(Method.POST);
    request.UseDefaultCredentials = true;
    request.AddHeader("content-type", "application/json");
    request.AddParameter("application/json", data, ParameterType.RequestBody);
    IRestResponse response = client.Execute(request);
    return response.Content;


  3. Set the registry entries for MaxFieldLength and MaxRequestBytes to the max allowed.



Log from stdout:




info: Microsoft.AspNetCore.Server.Kestrel[17]
Connection id "0HLIABLA41UKH" bad request data: "Request headers too long."
Microsoft.AspNetCore.Server.Kestrel.Core.BadHttpRequestException: Request headers too long. at Microsoft.AspNetCore.Server.Kestrel.Core.BadHttpRequestException.Throw(RequestRejectionReason reason) at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.Http1Connection.TakeMessageHeaders(ReadOnlySequence1 buffer, SequencePosition& consumed, SequencePosition& examined) at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.Http1Connection.ParseRequest(ReadOnlySequence1 buffer, SequencePosition& consumed, SequencePosition& examined) at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.Http1Connection.TryParseRequest(ReadResult result, Boolean& endConnection) at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.ProcessRequests[TContext](IHttpApplication1 application) at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.ProcessRequestsAsync[TContext](IHttpApplication1 application)
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[1]











share|improve this question
















I am working on an ASP.NET Core application which consumes a GraphQL endpoint via RestSharp to retrieve the data. This is an intranet type application, deployed on a Windows 2016 IIS Server and we are utilizing Windows Authentication. The problem we are encountering is that a certain user, who belongs to a large number of active directory groups is getting intermittent 431 Request headers too long errors.



I have attempted the following:





  1. I am setting the IISDefaults in the startup.cs for both the application and service:



    services.AddAuthentication(IISDefaults.AuthenticationScheme);



  2. I am passing UseDefaultCredentials in the RestRequest



    var client = new RestClient(endpoint);
    var request = new RestRequest(Method.POST);
    request.UseDefaultCredentials = true;
    request.AddHeader("content-type", "application/json");
    request.AddParameter("application/json", data, ParameterType.RequestBody);
    IRestResponse response = client.Execute(request);
    return response.Content;


  3. Set the registry entries for MaxFieldLength and MaxRequestBytes to the max allowed.



Log from stdout:




info: Microsoft.AspNetCore.Server.Kestrel[17]
Connection id "0HLIABLA41UKH" bad request data: "Request headers too long."
Microsoft.AspNetCore.Server.Kestrel.Core.BadHttpRequestException: Request headers too long. at Microsoft.AspNetCore.Server.Kestrel.Core.BadHttpRequestException.Throw(RequestRejectionReason reason) at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.Http1Connection.TakeMessageHeaders(ReadOnlySequence1 buffer, SequencePosition& consumed, SequencePosition& examined) at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.Http1Connection.ParseRequest(ReadOnlySequence1 buffer, SequencePosition& consumed, SequencePosition& examined) at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.Http1Connection.TryParseRequest(ReadResult result, Boolean& endConnection) at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.ProcessRequests[TContext](IHttpApplication1 application) at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.ProcessRequestsAsync[TContext](IHttpApplication1 application)
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[1]








c# iis asp.net-core kestrel-http-server






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 14 '18 at 19:31









Llazar

9681616




9681616










asked Nov 14 '18 at 19:19









Jonas WikJonas Wik

627




627













  • The user in question is a manager and member of 500+ Active Directory Groups.

    – Jonas Wik
    Nov 15 '18 at 16:12



















  • The user in question is a manager and member of 500+ Active Directory Groups.

    – Jonas Wik
    Nov 15 '18 at 16:12

















The user in question is a manager and member of 500+ Active Directory Groups.

– Jonas Wik
Nov 15 '18 at 16:12





The user in question is a manager and member of 500+ Active Directory Groups.

– Jonas Wik
Nov 15 '18 at 16:12












1 Answer
1






active

oldest

votes


















1














This was resolved by setting the MaxRequestHeadersTotalSize Kestrel option. This defaults to 32768.



        public static IWebHostBuilder CreateWebHostBuilder(string args) =>
WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>()
.UseKestrel(options =>
{
options.Limits.MaxRequestHeadersTotalSize = 1048576;
});





share|improve this answer























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53307363%2fiis-deployed-asp-net-core-application-giving-intermittent-431-request-headers-to%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














    This was resolved by setting the MaxRequestHeadersTotalSize Kestrel option. This defaults to 32768.



            public static IWebHostBuilder CreateWebHostBuilder(string args) =>
    WebHost.CreateDefaultBuilder(args)
    .UseStartup<Startup>()
    .UseKestrel(options =>
    {
    options.Limits.MaxRequestHeadersTotalSize = 1048576;
    });





    share|improve this answer




























      1














      This was resolved by setting the MaxRequestHeadersTotalSize Kestrel option. This defaults to 32768.



              public static IWebHostBuilder CreateWebHostBuilder(string args) =>
      WebHost.CreateDefaultBuilder(args)
      .UseStartup<Startup>()
      .UseKestrel(options =>
      {
      options.Limits.MaxRequestHeadersTotalSize = 1048576;
      });





      share|improve this answer


























        1












        1








        1







        This was resolved by setting the MaxRequestHeadersTotalSize Kestrel option. This defaults to 32768.



                public static IWebHostBuilder CreateWebHostBuilder(string args) =>
        WebHost.CreateDefaultBuilder(args)
        .UseStartup<Startup>()
        .UseKestrel(options =>
        {
        options.Limits.MaxRequestHeadersTotalSize = 1048576;
        });





        share|improve this answer













        This was resolved by setting the MaxRequestHeadersTotalSize Kestrel option. This defaults to 32768.



                public static IWebHostBuilder CreateWebHostBuilder(string args) =>
        WebHost.CreateDefaultBuilder(args)
        .UseStartup<Startup>()
        .UseKestrel(options =>
        {
        options.Limits.MaxRequestHeadersTotalSize = 1048576;
        });






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 30 '18 at 20:21









        Jonas WikJonas Wik

        627




        627
































            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53307363%2fiis-deployed-asp-net-core-application-giving-intermittent-431-request-headers-to%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Bressuire

            Vorschmack

            Quarantine