What happened to UrlParameter.Optional ?

instead of UrlParameter.Optional, you use the ? in the template to indicate an optional parameter

e.g. instead of:

routes.MapRoute(
    name: "Items",
    url: "items/{resource}",
    defaults: new { controller = "Root", action = "Items", resource = UrlParameter.Optional }
);

simply....

routes.MapRoute(
    name: "Items", 
    template: "items/{resource?}", 
    defaults: new { controller = "Root", action = "Items" }
);

Source

results matching ""

    No results matching ""