Controller中的代码以下:spa
public class HomeController : Controller
{
//
// GET: /Home/
orm
public ActionResult Index()
{
ViewData["test"] = "wtt";
return View();
}get
public string GetALL()
{
return "wtt";
}
}string
在index中:it
方法一:经过viewdata方法传值,此时index中直接调用@ViewData["test"];“test”是自随便取的名字io
方法二:在对应index中经过form表单接收, action="/Home/GetALL" 如:form
<form action="/Home/GetALL" method="get">
<button type="submit">denglu</button>
</form>class