0
routes.MapRoute(
"Route",
"{id}/{*seostuff}",
new {controller = "Home", action="Index", seo = UrlParameter.Optional});

that will allow you to map urls such as http://www.somesite.com/11/whatever/goes-here/will-be-whatever-you/want

Here is the original post Asp.net MVC custom routing

Hi guys!

-what I want to know is how can this be code in controller? I have a static page like this Product/Phone/i-phone.aspx which is under the product it has a folder phone.. . any suggestion guys? thank you very much.. .

1 Answer 1

0

You can define the route you have described...

        routes.MapRoute(
            "Route", // ShopsToRent/0/B31 5EH/9/0/0/0/0/0
            "{id}/{seo}", // URL with parameters
            new
            {
                controller = "ControllerName",
                action = "ActionName",
                page = UrlParameter.Optional,
                title = ""
            } // Parameter defaults
        );

I personally prefer to have a Keyword at the start of the url as this gives you an additional keyword (eg www.keywords.com/keywords )and allows future additions to the site...

        routes.MapRoute(
            "Route", // ShopsToRent/0/B31 5EH/9/0/0/0/0/0
            "KEYWORD/{id}/{seo}", // URL with parameters
            new
            {
                controller = "ControllerName",
                action = "ActionName",
                page = UrlParameter.Optional,
                title = ""
            } // Parameter defaults
        );
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.