日期:2014-05-17  浏览次数:20462 次

MVC当中,如何进行参数传递和参数值的获取?
比如我以前有一个页面:
www.test.com/proList.aspx?page=1&qu=window&type=system
现在用MVC做就变成了这样的地址:
www.test.com/proList?page=1&qu=window&type=system

proList对应的ActionResult 里面要如何才能获取到地址栏的参数,参数位置应该可以随便换吧?
www.test.com/proList?page=1&qu=window&type=system和
www.test.com/proList?qu=window&type=system&page=1这个是一个意思吧?


另外在一个控制器里面执行完代码后,我要跳转到其他页面并带上一个参数,请问要怎么做?
比如:
        [LoggerFilter()]
        [ExceptionFilter()]
        public ActionResult PostCreate()
        {
            String stTitle = Request.Form["title"];
            String stContent = Request.Form["content"];
            String stDate = Request.Form["updatedate"];

            InfoList il = new InfoList()
            {
                ID = 0,
                ClassID = int.Parse(Request.Form["myclass"]),
                Title = Request.Form["title"],
                Content = Request.Form["content"],
                UpdateDate = DateTime.Parse(Request.Form["updatedate"])
            };
            IContentService iis = ServiceBuilder.BuilderContent();
            iis.Add(il);
            ViewData["infolist"] = il;



            System.Threading.Thread.Sleep(2000);
            ViewData["timess"] = DateTime.Now;
            System.Threading.Thread.Sleep(3000);
            //这里执行完毕后我要跳转到:
www.test.com/postSuccess这个地址,但是需要带一些参数,比如:
www.test.com/postSuccess?post=true&userid=2048&lang=zh-cn
            return View("postSuccess?post=true&userid=2048&lang=zh-cn");这样好像会报错
        }

小弟初学MVC,烦请大家请教!谢谢!


------解决方案--------------------
Request.QueryString["updatedate"]
------