开发者

asp.mvc change controller name in request path

In my MVC project I have a controller names ProjectController and in pa开发者_JS百科th it looks like /project. I want to have the path for that "/proiect" .. is there any easy way to achieve that without renaming the controller class?

Thanks, Radu


You should be able to accomplish this with routing

routes.MapRoute(
    "Misspelling",
    "proiect/{action}",
    new { controller = "project", action = "index" }
);     


Yes, you can modify the rewrite-rules in the Global.aspx file.

        routes.MapRoute(
            "Default", // Route name
            "proiect/{action}/{id}", // URL with parameters
            new { controller = "Project", action = "Index", id = UrlParameter.Optional } // Parameter defaults
        );
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜