开发者

MVC routing doesn't pickup querystring

开发者 https://www.devze.com 2022-12-08 01:26 出处:网络
in my Global.ascx.cs, I have this setting for the routing: routes.MapRoute( \"HomeTarget\", \"{TargetCode}\",

in my Global.ascx.cs, I have this setting for the routing:

routes.MapRoute(
"HomeTarget",
"{TargetCode}",
new { controller = "Home", action = "Index", TargetCode = "" });

routes.MapRoute(
    "Default",                                              // Route nam开发者_开发问答e
    "{controller}/{action}/{id}",                           // URL with parameters
    new { controller = "Home", action = "Index", id = "" }  // Parameter defaults

In my HomeController, I have an Index() action like this:

[AcceptVerbs(HttpVerbs.Get)]
    public ActionResult Index(string TargetCode)
    {
        return View();
    }

When I go to the site, for example, mysite.com/Test1, I suppose it should take "Test1" as the TargetCode, but it didn't... What should I do for it to pickup the "Test1" as TargetCode, I don't want to do this: mysite.com/?TargetCode=Test1

Thank you very much, Kenny.


Seems like something's acting up on VS 2008 or with the framework. It's working nicely now. Thanks for looking.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号