0

When I try publishing the web api and deploying on my local iis, the setting below works

var builder = WebApplication.CreateBuilder(args);
builder.Services.Configure<IISServerOptions>(options => options.MaxRequestBodySize = 12000);

But in the server it doesn't work. I noticed that the deployment mode in web.config is different between my local and the server.

In my local:

hostingModel="inprocess"

while in the server it is:

hostingModel="OutOfProcess"

The IISServerOptions is for in-process. What should be the equivalent setting of MaxRequestBodySize that I should apply for out-of-process?

  • 1
    What are your reasons to use the legacy out-of-process mode? – Lex Li Jul 05 '23 at 05:56
  • Does it work if you change the setting hostingModel on the server to `inprocess`? – samwu Jul 05 '23 at 07:37
  • @LexLi not sure if it is ok to use `in-process` but I got "HTTP Error 500.34 - ASP.NET Core does not support mixing hosting models" error after I change it to `in-process` and change `builder.WebHost.UseIISIntegration();` to `builder.WebHost.UseIIS();` – user13663655 Jul 06 '23 at 01:31
  • @samwu not yet, please see my reply to Lex, the application pool configuration in the server might need to change. I will need to investigate. – user13663655 Jul 06 '23 at 01:39
  • That 500.34 indicates that in the same application pool you might have many ASP.NET Core web apps, which you never mentioned in the question. Can you move this web app to its own application pool so that in-process hosting mode can then work? – Lex Li Jul 06 '23 at 03:09
  • @Lex how iis application pool is configured is not decided by me and I don't have permission to access it as well. I think there is a script to control this and should not be modified. I think I will need to keep it out-of-process. If there isn't anything similar as `IISServerOptions` then I might need to do it in MiddleWare – user13663655 Jul 06 '23 at 05:34
  • @Lex I was thinking to make the settings in `web.config` but since we want the `web.config` file generation to be automatic without manual modification - I am not sure if there is a way for me to set the maximum request size in `dotnet publish` command – user13663655 Jul 06 '23 at 05:39
  • It is difficult to reproduce your problem based on your description, I suggest you open a case via: https://support.microsoft.com. – samwu Jul 10 '23 at 08:59

0 Answers0