How to remove controller name from URL in MVC project

前端 未结 4 1549
不思量自难忘°
不思量自难忘° 2020-12-12 05:43

I have a URL like below and I need to remove the controller name (myController). I\'ve use several fixes but none fixed the issue. Please help me guys..

http://fold

4条回答
  •  不思量自难忘°
    2020-12-12 06:05

    Enable attribute routing by adding following line before route.MapRoute in RouteConfig.cs file

    routes.MapMvcAttributeRoutes();
    

    Then add the Route Attribute to each action with the route name, like:

    [Route("MyAction")]
    public ActionResult MyAction()
    {
    ...
    }
    

提交回复
热议问题