1 获取参数
Request.Form:获取以POST方式提交的数据(接收Form提交来的数据); var data = Request.Form["data"];
Request.QueryString:获取地址栏参数(以GET方式提交的数据) var data = Request.QueryString["data"];
2 页面跳转
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[""] 保存在session里面 所有的控制器都能使用 但是用过一次,就清空了