forum

Home / DeveloperSection / Forums / Dynamic MVC Routing in asp.net mvc

Dynamic MVC Routing in asp.net mvc

Anonymous User 2167 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>


Updated on 10-Nov-2014
I am a content writter !

Can you answer this question?


Answer

1 Answers

Liked By