How do I change the url in MVC 5?

丶灬走出姿态 提交于 2019-12-06 06:19:47

Use ActionName attributes which allows you to give action name for controller method regardless of method name.

   [ActionName("Master-Fanchise")]
    public ActionResult Master()
    {
        return View();
    }

Have you enabled attribute routing as it is not turned on by default

public class RouteConfig
{
    public static void RegisterRoutes(RouteCollection routes)
    {
        routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
        //Add this line of code
        routes.MapMvcAttributeRoutes(); 

    }
}

you may also need to change the controller

[Route("~/ControllerName/Master-Fanchise")]
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!