-
Notifications
You must be signed in to change notification settings - Fork 10.3k
IHostingEnvironment.IsDevelopment() lowering Request Size limit #9918
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
IsDevelopment only checks state, it doesn't change anything. What are you doing in
What is null? |
See #8293 for adding IHttpMaxRequestBodySizeFeature to IIS in-process. |
The property MaxRequestBodySize is null. For the //Dev services Added I'm making It looks like I was wrong, about how to cause the issue I'm facing. Apparently IIS Express is keeping my site running in the background and just replacing the binaries, which was giving me false positives. I can use the IHostingEnvironment.IsDevelopment() call and ConfigureDevelopmentServies(......) call, and they both give me the same behavior. I was even wrong with the following attribute helping with the issue.
So I have two controllers with different endpoints controller1/SmallRequestApi On a fresh start where the IISExpress Site has been stopped completely, here is the behavior I'm seeing, in the order of my request calls. controller2/BiggerRequestApi Return 413 status code *Note All Calls will fail with a 413 at this point ** Normal behavior after this point. ------- Stop the web project but do not stop the IISExpress Site ---------------------- controller2/BiggerRequestApi Returns 200 status code Normal behavior after this point. ----------- If I stop the web project but not stop the IISExpress Site but wait awhile (like 5 minutes or so ---------- controller2/BiggerRequestApi Return 413 status code *Note All Calls will fail with a 413 at this point ** Normal behavior after this point. If I stop the IISExpress site for my local development and try this order of operations I get the following behavior controller1/SmallRequestApi Returns 200 status code Normal behavior after this point. I have made a simple middle ware component to see which features are getting added where
The first call to the endpoint controller2/BiggerRequestApi returned a 413 without hitting my breakpoints in my test middleware |
Can you share a minimal repro project with us? |
I will attempt to do so but it may take some time to strip and replicate the issue out |
took a good bit of testing but here is a repo of the issue https://github.com/Frankwayne/asp-net-core-413 there is a linqpad script in the scripts folder that you can use after you spin up the webserver. Apparently it doesn't matter for the IISExpress reset. each run of the script output the 413 for the Large Request Message , then a 200 for the small request size, then 200 for each Large Request call |
Strange using the Http paths appear to work just fine. |
https://docs.microsoft.com/en-us/iis/configuration/system.webserver/serverruntime It appears that it defaults to the serverruntime attribute value uploadReadAheadSize default value of 1 ) Small request size is send to other endpoint and 200 Changing the attribute value in the .vs/config/applicationhost.config file does not appear to effect this behavior sadly. It would appear that I need to add my own web.config file and then set this attribute. Since I'm using .Net Framework 4.7 instead of .net core my process is an out of memory process. This has solved my issue. https://docs.microsoft.com/en-us/aspnet/core/host-and-deploy/iis/?view=aspnetcore-2.2 |
@Tratcher I'm not sure if you wish to consider this a bug or not |
From your description this is an IIS behavior, not an Asp.Net behavior. I don't quite understand how it manifested in this way. @jkotalik @shirhatti |
I'm not either. I think it has something to do with the reverse proxy that is being set up for an out of memory kestrel server. The reverse proxy may not know the settings on the kestrel server for the maximum request size until a request comes through. When that request comes through it set the settings for the kesetrel server to the IIS reverse proxy for that connection. of course that is just a hypothesis. |
IIS request size limits would be applied independently of Kestrel. If you hit the IIS limit then the request shouldn't reach Kestrel. |
@Tractcher which is what I believe was happening. IIS was blocking my connection with 413, until an TCP connection was made with the server. At leas that is what I believed was happen with the linqpad script. Each run of the linqpad script would throw a 413 so It wasn't just loading the configuration into the two server. Its like IIS express forgot the setting on each run and would block until a connection was made then somehow allow in my larger sized payloads |
I have posted this on stack overflow but no bites yet. I was wondering if anyone else has seen this behavior before.
https://stackoverflow.com/questions/55941369/ihostingenvironment-isdevelopment-lowering-request-size-limit
Here is a copy of my stackoverflow question below
I'm having an issue where using the method call IHostingEnvironment.IsDevelopment() is causing 413 to be thrown back by the web server. When I remove this call, My method works with the same request.
I'm not sure if it is somehow lowering the DefaultRequestSize limit of 30MB aspnet/Announcements#267
or if there is something else going on that I do not know about.
I have alleviated the problem by removing the IHostingEnviornment.IsDevelopment() call out of the ConfigureServices(IServiceCollection) method in my startup class by moving my custom service configuration into
ConfigureProductionServices(IServiceCollection) and ConfigureDevelopmentServices(IServiceCollection)
and removing the call to the IHostingEnvironment.ISDevelopment() but I want to know what is going wrong with the above method as it should be supported.
https://docs.microsoft.com/en-us/aspnet/core/fundamentals/environments?view=aspnetcore-2.2
I have configured my Startup constructor to take the following input
where I call the env variable in my ConfigureSerivces method
The above configuration setup some how cause 413 to return from my web api calls when before they used to work.
I have worked around the issue with the issue with the following code methods
but I can't help the feeling that this will come back to bite me one day.
I can also use the follow attribute on my controller method to also fix this issue
[DisableRequestSizeLimit]
but it does have to be placed above the Route Attribute for some reason. I have no desire to use this fix as I feel its pretty unsafe, and I'm still clueless on what is going on.
I have place the following line of code in one controller and debugged the application with both startup designs but I still get a null value for both designs in my controller method call.
The text was updated successfully, but these errors were encountered: