Method not found: 'Asp.Versioning.ApiVersion Asp.Versioning.IApiVersionParser.Parse(System.String)'
MHKarami97 opened this issue · 1 comments
MHKarami97 commented
I use this code to add version on .net freamwork 4.6.2:
Asp.Versioning.WebApi : 7.0.0
Asp.Versioning.WebApi.ApiExplorer : 7.0.0
config:
config.MapHttpAttributeRoutes();
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/v{apiVersion}/{controller}/{action}/{id}",
defaults: new { id = RouteParameter.Optional }
);
config.AddApiVersioning(options =>
{
options.ReportApiVersions = true;
options.AssumeDefaultVersionWhenUnspecified = true;
options.Conventions.Add(new VersionByNamespaceConvention());
options.DefaultApiVersion = new ApiVersion(1, 0);
options.ApiVersionReader = ApiVersionReader.Combine(
new UrlSegmentApiVersionReader(),
new HeaderApiVersionReader("x-api-version"),
new MediaTypeApiVersionReader("x-api-version"));
}
);
SwaggerConfig.Register(config);
controller
[HandleError]
[ApiVersion("1")]
[System.Web.Http.AllowAnonymous]
[Route("api/v{version:apiVersion}/[controller]/[action]")]
public class BaseController : ApiController
{
}
[ApiVersion("1")]
public class CustomerController : BaseController
{
}
but when call api method like this, I get error:
http://localhost:63593/api/v1/Customer/GetErrors?userCode=1
<Error ml-update="aware" ml-stage="preload" ml-view="top">
<Message>An error has occurred.</Message>
<ExceptionMessage>Method not found: 'Asp.Versioning.ApiVersion Asp.Versioning.IApiVersionParser.Parse(System.String)'.</ExceptionMessage>
<ExceptionType>System.MissingMethodException</ExceptionType>
<StackTrace> at Asp.Versioning.ApiVersionRequestProperties.get_RequestedApiVersion() at Asp.Versioning.Dispatcher.ControllerSelectionContext.get_RequestedVersion() at Asp.Versioning.Dispatcher.DirectRouteControllerSelector.SelectController(ControllerSelectionContext context) at Asp.Versioning.Dispatcher.ApiVersionControllerSelector.SelectController(HttpRequestMessage request) at System.Web.Http.Dispatcher.HttpControllerDispatcher.<SendAsync>d__15.MoveNext()</StackTrace>
</Error>
mkArtakMSFT commented
Thanks for contacting us. This seems to be a question about the ASP.NET Core API Versioning library. Please file an issue over there as this is probably caused by a change in their APIs.