I am using web api 1 mvc 4
I have following code
public void save(int id , string name, string code = "")
{
}
I have following mapping in webapi.config.
config.Routes.MapHttpRoute(
name: "saveproduct",
routeTemplate: "api/product/save/{id}/{name}/{code}.{ext}",
defaults: new
{
controller = "product",
code = RouteParameter.Optional,
action = "save"
});
Now If I call
localhost://api/product/save/1/book/p23.json
It works
But
localhost://api/product/save/1/book/.json
It does not work
The reason I found is because optional parameter "code" is in between.
How can I make it work.. As I need extension must at the end with optional parameter like "code".
I found url , but could not got anything related.
Thanks