MVC路由不皮卡查询字符串

编程入门 行业动态 更新时间:2024-10-27 22:29:48
本文介绍了MVC路由不皮卡查询字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

在我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路由不皮卡查询字符串

本文发布于:2023-11-13 01:21:08,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1583015.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:路由   字符串   皮卡   MVC

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!