我试图消除“家”形成了自己的网址,所以换句话说:无法获取路由重命名URL
www.domain.com/home/about/变得www.domain.com/ aboutus
问题是,家庭没有被删除,我不能解决原因。我can see others have identical questions with near identical answers as to mine here on on SO所以我不知道为什么这不起作用。
我的Global.asax是
using System.Web.Http;
using System.Web.Mvc;
using System.Web.Routing;
namespace Company.Ui
{
// Note: For instructions on enabling IIS6 or IIS7 classic mode,
// visit http://go.microsoft.com/?LinkId=9394801
public class MvcApplication : System.Web.HttpApplication
{
protected void Application_Start()
{
AreaRegistration.RegisterAllAreas();
WebApiConfig.Register(GlobalConfiguration.Configuration);
FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
RouteConfig.RegisterRoutes(RouteTable.Routes);
}
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute("RemoveHomeUrl", // Route name
"{action}", // URL with parameters
new { controller = "Home", action = "Index" } // Parameter defaults
);
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
);
}
}
}
我的ActionLink的代码是:
@Html.ActionLink("About us", "AboutUs", "Home", null, new { @class = "mega" })
当我将鼠标悬停在一个链接,当我点击链接,它仍然会返回www.domain.com \家\关于我们
我在调试模式下在Visual Studio中运行这个2012年
我在一个损失,任何人都可以帮忙吗?
请在您的帖子中显示您的所有路线。你是否离开了'默认'?你有其他人吗? – 2013-05-04 13:29:04
@DaveA,我做了更新,并且显示了我的整个Global.asax文件。只有2条路线。 – Dave 2013-05-04 13:52:52
如果您删除'Default'会发生什么?它仍然使用'/ Home'渲染? – 2013-05-04 13:53:45