How does WCF WebApi map a request URI to the appropriate service type / operation?

天大地大妈咪最大 提交于 2019-12-04 17:20:57

By using the MapServiceRoute<TService>, the code is actually registering a ServiceHostFactory in the ASP.NET routing table. So first, the request arrives at ASP.NET, and that directs it to the service EmployeesResource (which is the only route to which the URL can be mapped). At that point, the WCF Web API service host (HttpConfigurableServiceHost) will use the UriTemplateTable to dispatch the request to the appropriate operation: if you have something like the code below, that's the operation which will be called:

[WebGet(UriTemplate = "/{employeeName}")]
public Employee Get(string employeeName);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!