How to Change ASP.NET MVC Controller Name in URL?

后端 未结 5 1968
挽巷
挽巷 2020-12-17 09:56

If we have \"example_name\" we can change it in url using [ActionName(\"\")] So, i want to do this for controller name.

I can do t

5条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-17 10:51

    You can use Attribute Routing.

    [RoutePrefix("Users")]
    public class HomeController : Controller
    {
        //Route: Users/Index
        [Route("Index")]
        public ActionResult Index()
        {
            return View();
        }
    }
    

提交回复
热议问题