当前位置: 代码迷 >> ASP.NET >> MVC 后台获取参数解决思路
  详细解决方案

MVC 后台获取参数解决思路

热度:9445   发布时间:2013-02-25 00:00:00.0
MVC 后台获取参数
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 />
<%}%>
  相关解决方案