I am redirecting from default page to home page. user has been resolved successfully in the action method. But not the user in tc instance. My default page (previous page) is not strongly typed.
public class HomeController : Controller
{
//
// GET: /Home/
public ActionResult Index(string user, TestClass tc)
{
ViewBag.Name = user; // resolved successfully
ViewBag.TCName = tc.user; // its null
return View();
}
}
public class TestClass
{
public string user;
}
** Default Page's .cshtml code piece**
<form action="Home" method="post">
<fieldset>
<legend>HTML 5</legend>
<label for="user">required</label>
<input id="user" type="text" name="user" required="required">
My question is why tc.user is null? [Isn't model binding just string to string match from post variables? if so, tc.user should have been populated as user in action method right?]