I have been having issues setting up my custom WebApi route in C#. I am setting up a custom route that uses a company name a parameter. The route works fine, unless the company name ends with a "." I have tried setting double escape but keep getting a 404 error.
Route
config.Routes.MapHttpRoute(
name: "Contracts",
routeTemplate:"{company}/Contracts/{action}/{id}",
defaults: new {controller= "Contracts", id= RouteParameter.Optional}
);
Controller
public class ContractsController : ApiController
{
[HttpGet, ActionName("PrivacyStatements")]
public HttpResponseMessage GetPrivacyStatements(string Company)
{
//code for privacy statements
}
These will work:
http://localhost/Company%20Name/Contracts/PrivacyStatements
http://localhost/Company.%20Name/Contracts/PrivacyStatements
http://localhost/Contracts/PrivacyStatements?Company=Company%20Name%20Inc.
This does not work:
http://localhost/Company%20Name%20Inc./Contracts/PrivacyStatements
the "." before the "/" in "/Company Name Inc./" always gives me a 404.
Any help is appreciated.