prettyjersie
New Member
I have a Web API service as below:\[code\][HttpGet]public UserProfile SearchByEmail(string siteName, string providerName, string email){}\[/code\]I'd like to make the providerName optional and the below urls should work:\[code\]{0}: http://www.domain.com/sites/siteName1/providerName1/User/SearchByEmail?email=email1{1}: http://www.domain.com/sites/siteName1/User/SearchByEmail?email=email1\[/code\]I've written the below mapping:\[code\] config.Routes.MapHttpRoute( name: "SearchUserByEmail", routeTemplate: "sites/{siteName}/{providerName}/User/SearchByEmail", defaults: new { controller = "User", action = "SearchByEmail", providerName = UrlParameter.Optional });\[/code\]but it only supports the {0} url and doesn't work with the {1} url.How to write the mapping so that it allows me make the providerName optional?