'.netcore 6.0 Querystring length causing badrequest

having issue when i am passing 2048 bit encrypted string (very long set of characters) in Querystring and keep getting bad request. I tried the following requestlimits in web.config - doesnt work configure Kestrel options - MaxRequestLineSize - it works only if the application is started as exe but does not work when launched with IISExpress or IIS - both out of process and in process. Configure in startup - MaxRequestBodySize

Following is my web.config as requested

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <location path="." inheritInChildApplications="false">
    <system.webServer>
      <security>
        <requestFiltering >
          <requestLimits maxAllowedContentLength="2147483647" maxUrl="2147483647" maxQueryString="2147483647" />
        </requestFiltering>
      </security>
      <handlers>
        <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
      </handlers>
      <aspNetCore processPath="dotnet" arguments=".\ACServicesIntegrationAPI.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" />
    </system.webServer>
  </location>
  <system.web>
    <httpRuntime  maxUrlLength="40960" maxQueryStringLength="2097151" maxRequestLength="40960" />
  </system.web>
</configuration>

tried this as well

Host.CreateDefaultBuilder(args)
                .ConfigureWebHostDefaults(webBuilder =>
                {
                    
                   
                    webBuilder.UseStartup<Startup>();
                    webBuilder.ConfigureKestrel((context, options) =>
                    {
                        options.Limits.MaxRequestLineSize = 32768;
                    });
                    
                });

Any ideas/solution?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source