0

Define route this way? Can anyone tell me how it will be used if i have to lang option on

routes.MapRoute(
            name: "Default",
            url: "{lang}/{controller}/{action}/{id}",
            defaults: new { lang = UrlParameter.Optional, controller = "Home", action = "Index", identifier = UrlParameter.Optional }
        );

2 Answers 2

1

MVC will strictly pattern-match, whether you said that the lang-Parameter is optional or not:

a/b/c/d

=> lang = a, controller = b, action = c, id = d.

a/b/c

=> lang = a, controller = b, action = c, id = null (because the default value says this is optional)

a/b

=> lang = a, controller = b, action = Index (because of the default value), id = null

etc.

Sign up to request clarification or add additional context in comments.

Comments

0

It depends on what are you use

For routing you can use: Sammy.Js + Knockout

Or Angular - Angular had nice routing

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.