Closed
Description
I pulled the sample aspne-api-versioning and tried adding $batch to the ODataBasicSample project and it did not work.
I followed the instructions in the wiki but still nothing. It seems like it's trying to obtain the IApiVersioningFeature but that's returning a null so it's not able to access anything else.
Here's my setup:
public void ConfigureServices( IServiceCollection services )
{
services.AddControllers();
services.AddApiVersioning(
options =>
{
options.ReportApiVersions = true;
options.RegisterMiddleware = false;
} );
services.AddOData().EnableApiVersioning();
}
public void Configure( IApplicationBuilder app, VersionedODataModelBuilder modelBuilder )
{
app.UseODataBatching();
app.UseApiVersioning();
app.UseRouting();
app.UseEndpoints(
endpoints =>
{
var models = modelBuilder.GetEdmModels( "api" );
var batchHandler = new DefaultODataBatchHandler();
endpoints.MapControllers();
endpoints.MapVersionedODataRoute( "odata", "api", models, batchHandler );
} );
}
Here's the error message I get:
System.NullReferenceException
HResult=0x80004003
Message=Object reference not set to an instance of an object.
Source=Microsoft.AspNetCore.Mvc.Versioning
StackTrace:
at Microsoft.AspNetCore.Mvc.Routing.ApiVersionUrlHelper.get_RouteParameter() in ...\Microsoft.AspNetCore.Mvc.Versioning\Routing\ApiVersionUrlHelper.cs:line 37