Thanks for reading this.
Want to pass data from querystring to an action; the URL
MyController/MyAction?lob=a
Have tried this:
[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” is always null.
Any ideas?
You should only have the one MyAction method in your controller.
You can also remove the
[HttpGet]If you want to have a second MyAction for post, add
[HttpPost]to it, so the controller can determine which method to use.