MVC路由不皮卡查询字符串 [英] MVC routing doesn't pickup querystring

查看:104
本文介绍了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.com/Test1,我想这应该采取测试1为目标code,但事实并非如此......我应该怎么为它做皮卡的测试1为目标code,我不想这样做:mysite.com/?Target$c$c=Test1

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.

推荐答案

看起来像是对VS 2008或与框架演戏了。现在的工作很好。感谢您寻找。

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

这篇关于MVC路由不皮卡查询字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆