Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get FormCollection out controllerContext for Custom Model Binder

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 needs the FormCollection. For some reason I can find it. I thought it would have been controllerContext.HttpContext.Request.Form

like image 933
RailRhoad Avatar asked Oct 02 '09 17:10

RailRhoad


1 Answers

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.

like image 124
Haacked Avatar answered Sep 18 '22 04:09

Haacked