asp.net mvc - MVC 5, true SEO Friendly Routes -


i wanna make urls seo friendly. have seen lot of articles , other posts on subject, of them ends urls like: /products/34/my-handbag

i wanna end urls like: /gucci/my-handbag

i have controls product names "gucci" , "my-handbag", need routing send me products controller.

this working right now:

routes.maproute( name: "productdetails", url: "{brand}/{title}", defaults: new { controller = "productviews", action = "details", brand = "", title = "" }

any suggestions?

you're on right path. can generate url like: www.domain.com/gucci/some-gucci-product-name means of following route.

routes.maproute(  "default", // route name  "{brand}/{details}", // url parameters  new { controller = "productviews", action = "details", brand = urlparameter.optional, details = urlparameter.optional }// parameter defaults ); 

you can handle title, search product in db if it's unique. if have add unique number @ end of url like; www.domain.com/gucci/some-gucci-product-name-13456

routes.maproute(  "default", // route name  "{brand}/{details}-{id}", // url parameters  new { controller = "productviews", action = "details", brand = urlparameter.optional, details = urlparameter.optional, id=urlparameter.optional }// parameter defaults ); 

hope helps.


Comments

Popular posts from this blog

scala - 'wrong top statement declaration' when using slick in IntelliJ -

c# - DevExpress.Wpf.Grid.InfiniteGridSizeException was unhandled -

PySide and Qt Properties: Connecting signals from Python to QML -