Controller:
public class HomeController : Controller
{
//
// GET: /Home/
public ActionResult Index()
{
return View();
}
[HttpPost]
public ActionResult Index(string list1)
{
return View();
}
}
View(uses default layout):
@{
ViewBag.Title = "Index";
}
<h2>Index</h2>
@using (Html.BeginForm())
{
@Html.DropDownList("list1",
new SelectList(new[] { "Item 1", "Item 2", "Item 3" }))
<input type="submit"/>
}
<br />
<br />
After selecting value in DropDownList and submitting the form my application have same state that was before. For example if i had selected "item 3" after pressing "submit" i have selected "item 3". How does it work?
Upd:
I dont want to avoid it, just want to understand how its work.