0

I have discovered that ASP.NET Core (3.1) writes the incoming request body to Windows TEMP folder like this:

ASPNETCORE_1130e40d-8d60-43ba-b5d9-48cafcf1fefd.tmp

Inside the file I see the json that is sent in the request(POST) body.

Any idea why and how to disable this? This caused 100+GB of data causing 0 disk space.

Found this but don't know how it is related or how to fix it: https://github.com/dotnet/aspnetcore/pull/9015/files

3
  • Did you enable buffering ? Jul 15, 2020 at 9:56
  • @PrebenHuybrechts In the doc they say "Files are automatically deleted at the end of their associated requests" and it looks like that this is the problem because in my case the files are not deleted.
    – realPro
    Jul 15, 2020 at 11:55
  • @PrebenHuybrechts Please post an answer so that I can accept. Had to add the following code for the TEMP files to get deleted: app.Use(next => context => { context.Request.EnableBuffering(); return next(context); });
    – realPro
    Jul 15, 2020 at 13:23

1 Answer 1

3

You can enable buffering on the requests.

app.Use(next => context => 
{ 
  context.Request.EnableBuffering(); 
  return next(context); 
});

From the docs:

Remarks

Temporary files for larger requests are written to the location named in the ASPNETCORE_TEMP environment variable, if any. If that environment variable is not defined, these files are written to the current user's temporary folder. Files are automatically deleted at the end of their associated requests.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.