MVC 3剃刀视图中的网址(首页/关于)--->关于 [英] The url in the MVC 3 razor view (Home/About)---> About

查看:87
本文介绍了MVC 3剃刀视图中的网址(首页/关于)--->关于的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Visual Studio 2010中,我拥有带有剃刀视图引擎的基本mvc 3应用程序.有两个菜单"Home"和"About".当我单击有关网站上的URL时,显示的是家"/关于",我不希望关于"为家".当我点击关于"菜单时,我希望网址看起来只是/About
这样的东西.我怎样才能做到这一点.请给我一个解决方案.我在哪里做修复工作.

已更新:
我正在研究新的MVC 3剃刀视图.我在项目的开始.当我运行该应用程序时,地址栏中的URL会像http://localhost:1032/一样.当我单击关于"菜单时,URL就像http://localhost:1032/Home/About
在这里,我不希望关于"作为家庭"的孩子(家庭/关于").当我单击关于"菜单时,我希望URL看起来像http://localhost:1032/About.我该怎么做.我可以获取这些步骤吗?

I have that basic mvc 3 application with razor view engine in 2010 visual studio. there are 2 menues "Home" and "About" . when i click on about the url on the site shows like home/about i dont want the About as a child of home. when i click on the "about" menue i want the url to look just the /About
somethinl like that. how can i do that. can i get a solution please. where do i do the work to fix it.

Updated:
I''m working on the new mvc 3 razor view. I''m in the beginning of the project. when i run the application the url at the address bar goes like http://localhost:1032/. when i click on the about menue, the url goes like http://localhost:1032/Home/About
where I dont want the About as a child of Home ( Home/About). i want the url to look like http://localhost:1032/About when i click the about menue. How can i do it. can i get the steps please.

推荐答案



您的路线应如下所示


You route should look like this
routes.MapRoute(
        "Home", // Route name
        "Home", // URL pattern
        new { controller = "Home", action = "Index"} // Parameter defaults
    );
}

routes.MapRoute(
        "About", // Route name
        "About", // URL pattern
        new { controller = "About", action = "Index"} // Parameter defaults
    );
}


这篇关于MVC 3剃刀视图中的网址(首页/关于)--->关于的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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