15

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....

Community
  • 1
  • 1
Marty
  • 1,182
  • 2
  • 13
  • 22
  • It seems like this parameter didnt make it on 1.0 release. Take a look at this issue: https://github.com/aspnet/KestrelHttpServer/issues/475 – Gerardo Grignoli Aug 19 '16 at 22:04
  • This is a function of your front end server (e.g. IIS or NGinx). ASP.NET Core does not yet have a restriction on this value. – Tratcher Aug 19 '16 at 23:27

2 Answers2

18

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>
dotnetstep
  • 17,065
  • 5
  • 54
  • 72
  • 1
    This answer is in the correct ballpark, and I changed various pieces of configuration along the lines described here, but the FINAL change that got things working was with an update to my registry, described here: http://stackoverflow.com/questions/15004232/wcf-get-url-length-limit-issue-bad-request-invalid-url Note I'm using IIS Express, and this also required a reboot of my machine for the registry setting to take effect. – Marty Aug 20 '16 at 03:18