문제

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.

도움이 되었습니까?

해결책

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
  );
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top