Get FormCollection out controllerContext for Custom Model Binder

后端 未结 3 1919
醉梦人生
醉梦人生 2021-01-05 02:10

I had a nice function that took my FormCollection (provided from the controller). Now I want to do a model bind instead and have my model binder call that function and it n

3条回答
  •  清酒与你
    2021-01-05 02:40

    Try this:

    var formCollection = new FormCollection(controllerContext.HttpContext.Request.Form)
    

    FormCollection is a type we added to ASP.NET MVC that has its own ModelBinder. You can look at the code for FormCollectionBinderAttribute to see what I mean.

提交回复
热议问题