[英]MVC3 null Querystring Returned To Action Method
It seems that once I define my Form like --> 似乎一旦我定义了我的表格->
using (Html.BeginForm("Create", "MyController", FormMethod.Post, new { id = "myForm" })) 使用(Html.BeginForm(“ Create”,“ MyController”,FormMethod.Post,新建{id =“ myForm”}))
The additional parameters being passed are now null. 现在,传递的其他参数为空。
MyController/Create/4?pid=61&status=Initiated MyController / Create / 4?pid = 61&status =已启动
pid and status returns null although the parameters are being passed as above. 尽管如上所述传递参数,但pid和status返回null。 What is causing these querystring parameters to be be null?
是什么导致这些querystring参数为null?
Using Request["myparameter"] or simply getting value from action method parameter returns null. 使用Request [“ myparameter”]或仅从操作方法参数获取值将返回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" />
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.