ASP.NET Web API RTM and subdomain routes

后端 未结 2 1533
终归单人心
终归单人心 2021-02-10 14:42

I am having issues getting Web API to work with subdomain-based routes. In short, I am getting to the right controller and method but the data token out of the subdomain is not

2条回答
  •  清歌不尽
    2021-02-10 15:20

    Thanks for reporting the issue. I used your repro at https://github.com/woloski/AspNetWebApiWithSubdomains and did some debugging.

    Here is why it is happening. The HttpDomainRoute.GetRouteData is not being called because it was wrapped by an internal class called HttpWebRoute in Web API. When you use config.Routes.Add method to add your custom route, instead of calling the HttpDomainRoute.GetRouteData, it will simply call the System.Web.Routing.Route's implementation of GetRouteData. That is why you see the rest of parameters being mapped correctly except the tenant.

    I can't think of any easy workaround on top of my head. I can file a issue at the codeplex site at http://aspnetwebstack.codeplex.com/ to track this issue.

提交回复
热议问题