C#.NetMVC基本传参
1.Controller->View
public ActionResult Index() {
ViewBag.Name = "Hello World!";
ViewData["Name"] = "Hello World!";
List<string> items = new List<string>
{
"hello","world","test"
};
return View(items);
}
html">@model List<string>@ViewBag.Name
@ViewData["Name"]
@foreach (string item in Model)
{
@Html.DisplayFor(model => item);
}
2.View ->Controller
<form action="/Home/About"> 姓名:<input type="text" name="name"><br>
地址:<input type="text" name="address"><br>
<input type="submit" value="提交">
</form>
public String About(string name,string address,Stu s) {
string name_ = Request["name"];
string address_ = Request["address"];
return name_ + address_;
}
以上是 C#.NetMVC基本传参 的全部内容, 来源链接: utcz.com/z/512712.html