vendredi 10 juin 2016

Dynamic routing from database in MVC 3

In my application I have stored seo- friendly URLs in database. I want that all the URLs to be mapped to same controller/action with URL name as parameter.

URL I want to show is xyz.com/{URL} E.g. xyz.com/general tuition/mathematics tuition *URL stored in database is - general tuition/mathematics tuition

I am unable to create route in global.asax please help.

What I am doing in global.asax is:

routes.MapRoute( "Class",
"{URLName}",
new { controller = "class", action = "classdetails" } );

Action: public ActionResult classdetails(string URLName){

}

Anchor that invokes route:

I am getting 404 when it is clicked or I enter URL in browser.

Aucun commentaire:

Enregistrer un commentaire