Ugly url in mvc3-how make it nice looking?
-
19-04-2021 - |
문제
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
);
제휴하지 않습니다 StackOverflow