An API version is required, but was not specified. webapi

我的未来我决定 提交于 2019-12-07 07:28:24

The ApiVersionUnspecified happens because all routes require an explicit API version by default. You opt out of this behavior using:

options.AssumeDefaultVersionWhenUnspecified = true

This setting means that a default API version is assumed when a client doesn't provide one. The default value is:

options.DefaultApiVersion // equals 1.0 by default

When you use the URL segment versioning method, you can't have two different controllers that both an unversioned route. The route without an API version can only map to a single controller. Since the default is "1.0" and you have a controller with the unversioned route, that's the one that will always been matched.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!