AspNetCoreOData
AspNetCoreOData copied to clipboard
Method HEAD is not allowed on $metadata
Hello,
Version Microsoft.AspNetCore.OData, Version=8.0.4.0
Seems default controller doesn't allow HEAD method requests on $metadata requests: http://www.xx.com/api/<CustomerId>$metadata": The remote server returned an error: (405) Method Not Allowed.
/// <summary>
/// Represents a controller for generating OData service and metadata ($metadata) documents.
/// </summary>
public class MetadataController : ControllerBase
{
private static readonly Version _defaultEdmxVersion = new Version(4, 0);
/// <summary>
/// Generates the OData $metadata document.
/// </summary>
/// <returns>The <see cref="IEdmModel"/> representing $metadata.</returns>
[HttpGet]
public IEdmModel GetMetadata()
{
return GetModel();
}
I use it to make sure my customer's model is online and not to download XML.
Any reason why being so restrictive?
Kind regards
@JL-Ikosoft If the built-in metadata routing can't meet you, you can build your own routing convention.
Hi, did you find anything? i also have problem i latest version but in odata endpoind
services.AddControllers().AddOData(opt => opt .Count().Filter().Expand().Select().OrderBy().SetMaxTop(null) .EnableQueryFeatures() .AddRouteComponents("odata", GetEdmModel(), services => services.AddSingleton<ODataBatchHandler, DefaultODataBatchHandler>()) );
Request HTTP/1.1 HEAD http://localhost:5000/odata/ (CORS policy execution successful) but i have error "Executed endpoint '405 HTTP Method Not Supported'"

i also run bouth app in this same server and port

I would also be interested in a solution and have a very similar case to @siasty. If the framework doesn't offer this by default, where could I put in my own metadata routing?
Ok, I seemingly solved it by using a Method Handler:
[HttpHead("odata/")]
public IActionResult MetadataHead()
{
return Ok();
}
i have solution in my repo https://github.com/siasty/Ui5_Odatav4
@JanWerder I was also struggling with batch reqest they didn't have Access-Control-Expose-Headers = "OData-Version";