MVC 后台获取参数解决思路
MVC 后台获取参数
controllers 中我这么写
然后前台我这么写
现在问题是我再调试的时候 string aa = Request["userName"]; 这里的值是null
请问下我如何修改才能得到这个值?谢谢了。。。。。
------解决方案--------------------
<%using(Html.BeginForm("测试", "Indexs",FormMethod.Get)){%>
<%=Html.TextBox("userName",userName)%>
<input type=submit />
<%}%>
controllers 中我这么写
- C# code
[HttpGet] public ActionResult Indexs(int id) { string aa = Request["userName"]; string bb = aa + id.ToString(); return View(); }
然后前台我这么写
- C# code
<%: Html.TextBox("userName")%> <%: Html.ActionLink("测试", "Indexs", new { id=1 })%>
现在问题是我再调试的时候 string aa = Request["userName"]; 这里的值是null
请问下我如何修改才能得到这个值?谢谢了。。。。。
------解决方案--------------------
<%using(Html.BeginForm("测试", "Indexs",FormMethod.Get)){%>
<%=Html.TextBox("userName",userName)%>
<input type=submit />
<%}%>