0

If I want to make url like this:

www.site.com/UK/London/Jobs/98767

Routing url is like:

...
"{countryCode}/{city}/Jobs/{jobId}"
...

So here I need 4 parameters to build this url. Should I have all this four parameters in actionmethod whenever I call it?

1
  • It' really easy to find out writing the code... Commented Jan 12, 2012 at 22:35

1 Answer 1

2

If you're registering your route like this:

routes.MapRoute(
    "Default",
    "{countryCode}/{city}/Jobs/{jobId}}",
    new { controller = "Home", action = "Jobs"}
);

Your action would need 3 parameters:

public ActionResult Jobs(string countryCode, string city, int jobId)
{
    ...
}

The 3rd parameter "Jobs" is used for matching the route and doesn't make sense to pass in as a parameter.

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.