Asp.net mvc 3 MVC3-查询字符串为空
谢谢你阅读这篇文章 希望将数据从查询字符串传递到操作;网址 MyController/MyAction?lob=a 我试过这个:Asp.net mvc 3 MVC3-查询字符串为空,asp.net-mvc-3,Asp.net Mvc 3,谢谢你阅读这篇文章 希望将数据从查询字符串传递到操作;网址 MyController/MyAction?lob=a 我试过这个: [HttpGet] public ActionResult MyAction() { var model = new SModel(); model.lob = Request.QueryString["lob"]; return View(model); } [HttpGet] public ActionResult
[HttpGet]
public ActionResult MyAction()
{
var model = new SModel();
model.lob = Request.QueryString["lob"];
return View(model);
}
[HttpGet]
public ActionResult MyAction(string lob)
{
var model = new SModel();
model.lob = lob;
return View(model);
}
[HttpGet]
public ActionResult MyAction(FormCollection values)
{
var model = new SModel();
model.lob = values["lob"];
return View(model);
}
“lob”始终为空
有什么想法吗?控制器中应该只有一个MyAction方法 您还可以删除
[HttpGet]
public ActionResult MyAction(string lob)
{
var model = new SModel();
model.lob = lob;
return View(model);
}
如果您想为post设置第二个MyAction,请向其添加
[HttpPost]
,以便控制器可以确定使用哪种方法。是;我有HttpPost。我想删除“get”很有效。谢谢