It seems that once I define my Form like -->
using (Html.BeginForm("Create", "MyController", FormMethod.Post, new { id = "myForm" }))
The additional parameters being passed are now null.
MyController/Create/4?pid=61&status=Initiated
pid and status returns null although the parameters are being passed as above. What is causing these querystring parameters to be be null?
Using Request["myparameter"] or simply getting value from action method parameter returns null.
尝试这个
Html.BeginForm("Create", "MyController", new { pid = Request.QueryString["pid"] }, FormMethod.Post, new { id = "myForm" }))
What you are saying is very weird as the following works perfectly fine for me:
public class HomeController : Controller
{
public ActionResult Index()
{
return View();
}
[HttpPost]
public ActionResult Index(string pid, string foo)
{
// the pid and foo parameters are correctly assigned here
return View();
}
}
and in the view:
@using (Html.BeginForm("Index", "Home", new { pid = "63" }, FormMethod.Post, new { id = "myForm" }))
{
@Html.TextBox("foo", "some value")
<input type="submit" value="OK" />
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.