C# – Passing strongly typed viewdata to view page in asp.net-mvc

asp.net-mvcc

Do I have to manually pass my strongly typed viewdata to the call return View(); ?

ie.

MyViewData vd = new MyViewData();

vd.Blah = "asdf asdfsd";

return View();

It seems if I pass it as a parameter, I have to repeat the view name also?

return View("index", vd);

Best Answer

you can simply pass the model the the View method:

MyViewData vd = new MyViewData();

vd.Blah = "asdf asdfsd";

return View(vd);