Ugly url in mvc3-how make it nice looking?

131 views Asked by At

Have an action in Ideas controller in my aplication:

public ViewResult NewIdeas(int numberOfPage = 1)

that action "produces" url like that:

/Ideas/NewIdeas/?numberOfPage=1

it's quite ugly-it should be just:

/Ideas/NewIdeas/1

I know that new MapRoute propably will solve problem-but how it should look like? Thanks for help.

1

There are 1 answers

0
linkerro On BEST ANSWER

You should add a new route in global.asax:

  routes.MapRoute(
      "NewIdeas", // Route name
      "Ideas/NewIdeas/{numberOfPage}", // URL with parameters
      new { controller = "Ideas", action = "NewIdeas", numberOfPage= UrlParameter.Optional } // Parameter defaults
  );