Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MVC 5, [HttpPpost] Create method: Bind(Include = "List of Properties...") modifier - intended use?

Can someone shed some light on the use of the 'Bind' modifier in the following method signature?

    [HttpPost]
    [ValidateAntiForgeryToken]
    public ActionResult Create([Bind(Include = "List of model propertires.....")] MyModel model)
    {
    }

Can I use it to bind the posted values to a different model than the one I built the view with?

Thanks.

like image 363
Khalique Rehman Avatar asked Oct 20 '22 23:10

Khalique Rehman


1 Answers

Yes you can use the Bind to bind the values to a different model. The Bind Attribute lets you specify the exact properties a model binder should include in the binding.

like image 64
JayL Avatar answered Oct 22 '22 23:10

JayL