在我Global.ascx.cs,我有这样的设置路由:
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 name "{controller}/{action}/{id}", // URL with parameters new { controller = "Home", action = "Index", id = "" } // Parameter defaults在我的HomeController中,我有一个这样的Index()动作:
In my HomeController, I have an Index() action like this:
[AcceptVerbs(HttpVerbs.Get)] public ActionResult Index(string TargetCode) { return View(); }当我去到现场,例如,mysite/Test1,我想这应该采取测试1为目标code,但事实并非如此......我应该怎么为它做皮卡的测试1为目标code,我不想这样做:mysite/?Target$c$c=Test1
When I go to the site, for example, mysite/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/?TargetCode=Test1
非常感谢你,肯尼。
Thank you very much, Kenny.
推荐答案看起来像是对VS 2008或与框架演戏了。现在的工作很好。感谢您寻找。
Seems like something's acting up on VS 2008 or with the framework. It's working nicely now. Thanks for looking.
更多推荐
MVC路由不皮卡查询字符串
发布评论