views:

60

answers:

1

Hello,

When typing in my URL SalaryFor/Microsoft/Balmer i need to display salary for user with name Balmer and if I type in URL SalaryFor/Microsoft i need to display salary for all employee in Microsoft company

Is it possible? because when I use this link SalaryFor/Microsoft/Balmer all works fine

public ActionResult Salary(string company, string person)

both company and person contains values

but this link does not work SalaryFor/Microsoft

public ActionResult SalaryFor(string company, string person)

both values contains null

my route in global.asax is

    routes.MapRoute("Salary",
                    "{controller}/{action}/{company}/{position}",
                    new
                        {
                            controller = "Salary",
                            action = "SalaryFor",
                            company = "",
                            test = ""
                        });

O maybe I am making something wrong? Thanks, Alexander.

+2  A: 

You need to map a second route.

routes.MapRoute("Salary2",
                    "{controller}/{action}/{company}",
                    new
                        {
                            controller = "Salary",
                            action = "SalaryFor",
                            company = ""
                        });
Pino