简体   繁体   English

在ASP.NET MVC4中配置路由

[英]Configuration of routes in asp.net mvc4

i want to configure a new route, something like 我想配置一条新路线,例如

http://localhost:4889/Home/Search

for this i am trying to configure in RouteConfig.cs as follows, 为此,我尝试在RouteConfig.cs中进行如下配置,

  routes.MapRoute(
                name: "About",
                url: "{controller}/{action}/{id}",
                defaults: new { controller = "Home", action = "About", id = UrlParameter.Optional }
            );

But its not working. 但是它不起作用。 Whenever i try to hit that route it will redirect me login route, am i missing something? 每当我尝试点击该路线时,它将重定向我的登录路线,我是否缺少某些东西? Please let me know how to do this. 请让我知道该怎么做。

Your route definition matches "Default" route, you probably haven't modified it and it's defined before your "About" route. 您的路线定义与“默认”路线匹配,您可能尚未对其进行修改,并且在“关于”路线之前进行了定义。

Or maybe you missed [Authorize] Attribute somewhere 也许您错过了[Authorize]属性

I guess you want to delete this About route and just modify the Default one. 我想您想删除此关于路线,而只需修改默认路线。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM