1 acquisition parameters
Request.Form: acquiring data (received data to Form submission) POST method submitted; var data = Request.Form [ "data"];
Request.QueryString: obtaining address parameters field (the data submission GET) var data = Request.QueryString [ "data"];
Page 2 Jump
public actionResult Index
public ActionResult Index()
{
List<string>colors = new List<string>();
colors.Add("red");
colors.Add("green");
colors.Add("blue");
ViewBag.ListColors = colors; //colors is List
ViewBag.DateNow= DateTime.Now;
ViewBag.Name= "hejingyuan";
ViewBag.Age = 25;
return View();
}
View
<p>
My name is <b>@ViewBag.Name</b>, <b>@ViewBag.Age</b> years old.
<br />
I like the following colors:
</p>
<ul id="colors">
@foreach (var color in ViewBag.ListColors)
{
<li><font color="@color">@color</font> </li>
}
</ul>
<p>
@ViewBag.DateNow
</p>
4 base.TempData [ ""] to save all the controllers can be used in the session, but used once inside, they emptied