Watch this example on YouTube
So instead of
http://localhost:53071/Test/DisplayMessage/city=Kyiv?age=1500
I want user to access my page through this link
http://localhost:53071/Test/DisplayMessage/Kyiv/1500
In order to do so,
first create method called DisplayMessage in Test controller
public string DisplayMessage(string city, int age)
{
return HttpUtility.HtmlEncode("the following city: " + city + "is " + age.ToString() + "years old");
}
then modify RouteConfig.cs file inside App_Start folder and add the following
routes.MapRoute(
name: "Test",
url: "{controller}/{action}/{city}/{age}"
);
No comments:
Post a Comment