Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.Net Core maxUrlLength

Tags:

asp.net-core

Is there a way to set a maxUrlLength configuration value in Asp.Net Core? I see how this is done in web.config in earlier versions of the framework, for example:

How do I increase the maxUrlLength property in the config in asp.net MVC 3?

However, this doesn't seem to work in ASP.Net Core....

like image 291
Marty Avatar asked Aug 19 '16 21:08

Marty


2 Answers

You are correct that maxUrlLength configuration value not available is not available ASP.net core the way it is available in previous version. The clean reason for this is that previous version only support IIS and Windows so it is tightly integrated with that. Now It is supported with other OS and to do that the way they did it reverse proxy with actual server. Like In Windows IIS and Linux NGinx.

  1. IIS will communicate with Kestrel.
  2. NGIx will comminicate with Kestrel.

Now any request filtering or url setting we have to do is at IIS or NGinx level.

If you are working in Windows you will find "Request Filtering" feature and for that you have to add Web.config file. ( I have not tested NGInx)

You have to do something like this.

<system.webServer>
    <!--   Here you have other settings related to handlers.-->
   <security>
      <requestFiltering>
         <requestLimits maxAllowedContentLength="3000000" maxUrl="10241" maxQueryString="20481" />
      </requestFiltering>
   </security>
 </system.webServer>
like image 197
dotnetstep Avatar answered Sep 18 '22 17:09

dotnetstep


Maybe this can help

KestrelServerLimits.MaxRequestLineSize Property

https://docs.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.server.kestrel.core.kestrelserverlimits.maxrequestlinesize?view=aspnetcore-3.1#Microsoft_AspNetCore_Server_Kestrel_Core_KestrelServerLimits_MaxRequestLineSize

like image 36
100r Avatar answered Sep 20 '22 17:09

100r