Users Pricing

forum

home / developersection / forums / dynamic mvc routing in asp.net mvc

Dynamic MVC Routing in asp.net mvc

Anonymous User 2485 09 Nov 2014

I have Controller name: About and Action name: Index. But I want the URL to be like this (action name will be dynamically)

www.example.com/home/aaa www.example.com/home/bbb www.example.com/home/ccc

Routing

  routes.MapRoute(
                name: "Home",
                url: "{controller}/{name}",
                defaults: new { controller = "Home", action = "Index"}

Controller

public class AboutController : Controller
    {
        public ActionResult Index(string name)
        {
            return View();
        }
    }
}

View

@{
    ViewBag.Title = "Index";
}
<h2>Index About</h2>


I am a content writter !


1 Answers