C
C#5mo ago
Maskoe

Manually execute default ModelBinding from AspNetCore

For reasons I am in an ActionFilter and want to transform the IFormCollection I have into a model class. This is basically ModelBinding, I want to avoid writing a bunch of reflection and typing stuff myself. Where is this logic? I found Microsoft.AspNetCore.Mvc.ModelBinding.ModelBindingHelper, but I dont have access to it somehow. I basically just want something like ModelBindingHelper.TryUpdateModel(myForm) or my HttpContext or my ActionExecutingContext. I know I have A model in my ActionExecutingContext, but its not the one I need. Basically I want a simple way to bind form data to a model and I know aspnetcore does this internally. Where is this code? Can I use it? Can I steal it?
0 Replies
No replies yetBe the first to reply to this messageJoin