处理asp.net mvc中的missing和null参数

时间:2013-09-23 17:16:03

标签: c# asp.net-mvc

我是asp.net mvc的新手。

现在要求我必须在同一个ActionResult中处理以下URL

如果HTTP // jpripu / Handset / shop_code =& hosho_date =然后做点什么。

如果HTTP // jpripu / Handset / shop_code = Cust01& hosho_date = 20131212则执行某些操作

如果HTTP // jpripu / Handset / hosho_date =然后做某事

如果HTTP // jpripu / Handset / shop_code =然后做某事

分别执行上述条件是否可行? 任何人都可以帮我这个。感谢。

1 个答案:

答案 0 :(得分:1)

如果您指的是http://jpripu/shop_code=&hosho_date=20130923这样的网址 然后这个控制器适合你:

    public class HandsetController : Controller
    {
        public ActionResult Index(string shop_code, string hosho_date)
        {
            ViewBag.shop_code = shop_code;
            ViewBag.hosho_date = hosho_date;

            return View();
        }
    }

注意:索引 - 是默认操作,在路由中定义。

另外,我建议将Pluralsight Introduction to ASP.NET MVC 3个截屏视频作为ASP.NET MVC的快速启动。