-
Notifications
You must be signed in to change notification settings - Fork 67
Open
Description
With this path: "distributed-requisitions/feature-set?version={version}"
and this GET handler: public object Get([Optional]int? version) { ... }
and this configuration:
ResourceSpace.Has.ResourcesOfType<FeatureSetResource>()
.AtUri(DistributedRequisitionsConstants.FeatureSetPath)
.HandledBy<FeatureSetHandler>()
.TranscodedBy<AutomaticXmlWithHtmlStylesheetCodec<FeatureSetResource,FeatureSet>>();
I can GET that URL with and without "?version=XXX" in the URL. Handling of optional parameters works fine in this case.
But when I try to create a URI without the version parameter:
Uri url = typeof(FeatureSetResource).CreateUri(new { });
it fails:
System.InvalidOperationException: No suitable Uri could be found for resource with key CLR Type: FeatureSetResource with values .
at OpenRasta.Web.TemplatedUriResolver.CreateUriFor(Uri baseAddress, Object resourceKey, String uriName, NameValueCollection keyValues)
at OpenRasta.Web.IUriResolverExtensions.CreateUri(Object target, Uri baseUri, String uriName, Object additionalProperties)
at OpenRasta.Web.IUriResolverExtensions.CreateUri(Object target, Object additionalProperties)
If I add the "version" parameter it works:
Uri contentUri = typeof(FeatureSetResource).CreateUri(new { version = 9});
Problem 1: I would expect typeof(FeatureSetResource).CreateUri(new { }); to work since the "version" parameter is marked as optional.
Problem 2: I could not find any documentation of the use of [Optional] - only some ten years old Google group stories popped up. Is it the right way to handle optional parameters at all?
Metadata
Metadata
Assignees
Labels
No labels