You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
marking the controller type with [ODataAttributeRouting] (or inheriting from ODataController) and marking methods which should be excluded from OData with [ODataIgnored],
marking only certain methods of the controller with [ODataAttributeRouting].
Most of Asp.Versioning looks for ODataAttributeRoutingAttribute at both controller and action level. Unfortunately, ODataApplicationModelProvider checks the presence of this attribute at controller level only, by calling the static method ODataControllerSpecification.IsSatisfiedBy(ICommonModel model). This prevents method 2 above from working correctly, because the ODataApiVersionCollectionProvider.ApiVersions collection does not get populated, ODataMultiModelApplicationModelProvider does not get any models from VersionedODataModelBuilder and ultimately ODataRoutingMetadata is not set in the action endpoint metadata.
Expected Behavior
ODataApplicationModelProvider should consider all controller actions for which either 1) the controller is decorated with [ODataAttributeRouting] and the action is not decorated with [ODataIgnored], or 2) the action is decorated with [ODataAttributeRouting].
The issue is not very critical for my team, because we can mark the entire controllers with ODataAttributeRouting as a workaround. However, it was surprising, cost us some debugging time and the behavior is in conflict with the Microsoft documentation, so I wanted to leave at least a description of it here.
Thank you a lot for creating and maintaining this project!
The text was updated successfully, but these errors were encountered:
Is there an existing issue for this?
Describe the bug
In the application I'm working on there are several controllers which need OData to be enabled on specific actions only.
ASP.NET OData provides two ways of defining this:
[ODataAttributeRouting]
(or inheriting fromODataController
) and marking methods which should be excluded from OData with[ODataIgnored]
,[ODataAttributeRouting]
.Most of Asp.Versioning looks for
ODataAttributeRoutingAttribute
at both controller and action level. Unfortunately,ODataApplicationModelProvider
checks the presence of this attribute at controller level only, by calling the static methodODataControllerSpecification.IsSatisfiedBy(ICommonModel model)
. This prevents method 2 above from working correctly, because theODataApiVersionCollectionProvider.ApiVersions
collection does not get populated,ODataMultiModelApplicationModelProvider
does not get any models fromVersionedODataModelBuilder
and ultimatelyODataRoutingMetadata
is not set in the action endpoint metadata.Expected Behavior
ODataApplicationModelProvider
should consider all controller actions for which either 1) the controller is decorated with[ODataAttributeRouting]
and the action is not decorated with[ODataIgnored]
, or 2) the action is decorated with[ODataAttributeRouting]
.Steps To Reproduce
No response
Exceptions (if any)
No response
.NET Version
.NET 8.0.11, Microsoft.AspNetCore.OData 8.2.7, Asp.Versioning 8.1.0
Anything else?
The issue is not very critical for my team, because we can mark the entire controllers with ODataAttributeRouting as a workaround. However, it was surprising, cost us some debugging time and the behavior is in conflict with the Microsoft documentation, so I wanted to leave at least a description of it here.
Thank you a lot for creating and maintaining this project!
The text was updated successfully, but these errors were encountered: