aspnetcore: System.NullReferenceException at Microsoft.AspNetCore.Http.DefaultHttpRequest.get_HasFormContentType()

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

Sometime I got the error System.NullReferenceException at Microsoft.AspNetCore.Http.DefaultHttpRequest.get_HasFormContentType() for several GET API.

Expected Behavior

No response

Steps To Reproduce

No response

Exceptions (if any)

Error: Object reference not set to an instance of an object.System.NullReferenceException: Object reference not set to an instance of an object.
at Microsoft.AspNetCore.Http.DefaultHttpRequest.get_HasFormContentType()
at Microsoft.AspNetCore.Mvc.ModelBinding.FormValueProviderFactory.CreateValueProviderAsync(ValueProviderFactoryContext context)
at Microsoft.AspNetCore.Mvc.ModelBinding.CompositeValueProvider.CreateAsync(ActionContext actionContext, IList`1 factories)
at Microsoft.AspNetCore.Mvc.ModelBinding.CompositeValueProvider.TryCreateAsync(ActionContext actionContext, IList`1 factories)
at Microsoft.AspNetCore.Mvc.Controllers.ControllerBinderDelegateProvider.<>c__DisplayClass0_0.<<CreateBinderDelegate>g__Bind|0>d.MoveNext()

.NET Version

6.0.202

Anything else?

No response

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 15 (8 by maintainers)

Most upvoted comments

OK here’s the deal:

  • I won’t be able to help you diagnose the problem unless I have access to the source and or dumps.
  • If you’re running on windows, you might be able to use debug diag to get a crash dump when this happens
  • If you’re on Linux there are other ways but they are harder.

Read the other issue and see what the issue was and what the fix was. That will help you narrow your code down to what parts of your code might be a problem. It could be logger, direct usage of the telemetry client or indirect usage.