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....
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.
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>
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With