2

I want upload more than default ~30MB file on my website app

HTTP Error 404.13 - Not Found The request filtering module is configured to deny a request that exceeds the request content length.

Most likely causes: Request filtering is configured on the Web server to deny the request because the content length exceeds the configured value.

I google it and i set up Program.cs like this:

public static IWebHost BuildWebHost(string[] args) =>
            WebHost.CreateDefaultBuilder(args)
                .UseStartup<Startup>()
                .UseKestrel(options => { options.Limits.MaxRequestBodySize = null; })
                .Build();

and Startup.cs like this:

app.Run(async (context) =>
            {
                context.Features.Get<IHttpMaxRequestBodySizeFeature>()
                    .MaxRequestBodySize = null;

            });

i tried also set up attribute on my class for uploading file like this:

[HttpPost]
[DisableRequestSizeLimit]
[ValidateAntiForgeryToken]
public async Task<IActionResult> Create(CreateFileViewModel model)

but i still have same problem. I cant understand. Thank you for any advice.

Frantisek Pastorek
  • 508
  • 1
  • 8
  • 26
  • Possible duplicate of [IIS7 - The request filtering module is configured to deny a request that exceeds the request content length](https://stackoverflow.com/questions/10871881/iis7-the-request-filtering-module-is-configured-to-deny-a-request-that-exceeds) – CodeCaster May 31 '18 at 09:49
  • It's not ASP.NET Core that's blocking the request, it's IIS. See duplicate. – CodeCaster May 31 '18 at 09:49
  • 1
    ITS NOT DUPPLICATE i read it when i looked for problem on google but nothing working for me. I set up options for MaxRequestBodySize but still not working and i have no idea why. You just read title of this question... Very SAD – Frantisek Pastorek May 31 '18 at 09:51
  • Don't assume bad intent. The duplicate I link to talks about IIS configuration, not .NET Core configuration. Do you understand the difference? Your question mentions nothing about IIS. – CodeCaster May 31 '18 at 10:09
  • During running my applicaton also IIS must run. And I suppose problem can by into IIS of Visual Studio because i can change manualy MaxRequestBodySize on my IIS server. – Frantisek Pastorek May 31 '18 at 10:12
  • 1
    Yes, you can do that. Have you done so? Then please [edit] your question and show that. – CodeCaster May 31 '18 at 10:13
  • AGAIN i can change manualy MaxRequestBodySize on my IIS server not on server of Visual Studio. Visual Studio have own IIS server with own settings and i dont know how to change it. – Frantisek Pastorek May 31 '18 at 11:00
  • [Create a web.config file to configure the web server](https://stackoverflow.com/questions/42542328/web-config-missing-when-creating-asp-net-core-web-app-in-vs-2017-rc). – CodeCaster May 31 '18 at 11:01
  • See also: [HTTP Error 404.13 - asp.net core 2.0](https://stackoverflow.com/questions/46510836/http-error-404-13-asp-net-core-2-0). – CodeCaster May 31 '18 at 11:06
  • 2
    When I searched my problem on google i found every post what you linked me but nothing work. I found also your last link about creating new web.config but i thought that options what i set up in my post are same. I am not very smar as i see. My bad. And thank you very much and sorry for triggered. Nice day. – Frantisek Pastorek May 31 '18 at 11:15
  • No problem, happy to help. – CodeCaster May 31 '18 at 11:16
  • How can i mark your answer as accpeted answer? Or delte this question is better choice? – Frantisek Pastorek May 31 '18 at 11:47
  • This one: https://stackoverflow.com/questions/46510836/http-error-404-13-asp-net-core-2-0 answers your question. Flag your question as a duplicate of that one. Then other people, when they find this question, can find the answer there. – CodeCaster May 31 '18 at 11:48
  • Possible duplicate of [HTTP Error 404.13 - asp.net core 2.0](https://stackoverflow.com/questions/46510836/http-error-404-13-asp-net-core-2-0) – Frantisek Pastorek Jun 01 '18 at 08:15

1 Answers1

2

@Frantisek - Try changing value count limit for FormOptions in ConfigureServices method in Startup file.

services.Configure<FormOptions>(x => x.ValueCountLimit = 1000000);

By changing this you would be able to overcome default upload limit.

Bharat
  • 129
  • 7