Reputation: 9396
For an already agreed (between customer and us) URL like,
http://URL/companyapi/orders/100191/sendrequest?for=customer123&card=123451
I am defining a route map like this:
public static void Register(HttpConfiguration config)
{
config.Routes.MapRoute(
name: "Service",
routeTemplate: "companyapi/orders/{orderId}/{controller},
default: new{},
);
}
For retrieving other query string parameters, I think it is enough if I do this:
public void Get(string for, int card)
{
// How to retrieve the orderId ?
}
1. How to retrieve the orderId
because it comes before controller
portion in the route Template?
2. Is it perfectly normal to leave the default part of the MapRoute
function?
Upvotes: 0
Views: 54
Reputation: 34
Please add orderId parameter to Get Method.
public void Get(int orderId, string for, int card)
{
// How to retrieve the orderId ?
}
and change RouteConfig.cs file
public static void Register(HttpConfiguration config)
{
config.Routes.MapRoute(
name: "Service",
routeTemplate: "companyapi/orders/{orderId}/{controller},
default: new{},
);
}
to
public static void Register(HttpConfiguration config)
{
config.Routes.MapRoute(
name: "Service",
routeTemplate: "companyapi/orders/{controller},
default: new{},
);
}
Upvotes: 1