Difference between RouteTable.Routes and HttpConfi

2019-05-05 07:08发布

问题:

I am wondering why routes seem to be configurable from both the HttpConfiguration object and the RouteTable class? Clearly the two .Routes properties are not of the same type, but they seem to stay in-sync. Is there a chance they could get out-of-sync? I'm wondering though, from a Web API perspective, should RouteTable.Routes ever be used?

回答1:

The HttpConfiguration class is specific to WebApi making it reusable outside of IIS (e.g. For self hosting). The RouteTable version is for IIS only.