简体   繁体   中英

How to fix error “The request filtering module is configured to deny a request where the query string is too long”

I have asp.net core project, during publishing on IIS on my local computer it works. I moved my project folder to another computer IIS, and getting error "The request filtering module is configured to deny a request where the query string is too long". I am using cookies authentication

    services.AddAuthentication(options =>
    {
        options.DefaultSignInScheme = CookieAuthenticationDefaults.AuthenticationScheme;
        options.DefaultAuthenticateScheme = CookieAuthenticationDefaults.AuthenticationScheme;
        options.DefaultChal`enter code here`lengeScheme = 
        CookieAuthenticationDefaults.AuthenticationScheme;
    }) 

What can be a problem, if it work on my comp, why it doesn't work on another comp.

enter image description here

According to the error message, this issue is thrown by the IIS request filter module, I suggest you could try to add below web.config setting to extend the query string limit to avoid this error.

Open your asp.net core application web.config file and add below setting:

<system.webServer>
    <security>
        <requestFiltering>
            <requestLimits maxQueryString="8156" />
        </requestFiltering>
    </security>
</system.webServer>

Whole web.config example:

<configuration>
  <location path="." inheritInChildApplications="false">
    <system.webServer>
      <handlers>
        <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
      </handlers>
      <aspNetCore processPath="dotnet" arguments=".\WinAuthCore.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="InProcess" />
    </system.webServer>
  </location>
    <system.webServer>
        <security>
            <requestFiltering>
                <requestLimits maxQueryString="8156" />
            </requestFiltering>
        </security>
    </system.webServer>
</configuration>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM