Closed pmcevoy closed 10 years ago
I normally address that scenario with a custom route dispatcher.
Does this answer your question?
Hi Mark. Why wouldn't POST Uri generation be included in hyprlinkr instead of we having to resort to a custom route dispatcher? Thanks
Sorry for lack of feedback: I swapped to the SO posting and updated there. You can close this issue
@ricmrodrigues How would it work? It would need to reliably filter away any 'model' parameter representing data being POSTed, but still include other parameters, including, perceivably, query parameters.
Perhaps the ASP.NET Web API has a way to figure that out, but if so, I don't know how it works... I wouldn't mind adding the feature if it's possible, though...
Can't we rely on the [FromBody] for that?
Rely on? I don't know... I never use [FromBody]
... In fact, this is the first time I hear about this attribute.
Well, in that case, it wouldn't work. But you just rely on Web API figuring out what comes from where? I guess without [FromBody]
it wouldn't be possible. Could be a pre-req, is you don't use [FromBody]
you can't generate POST URIs.
Web API usually figures it out for me without problems, so I haven't looked into the details of how it does it.
Here's an example method signature:
public HttpResponseMessage Post(string id, ProductRendition productRendition)
Hi Mark, I would like to create a link to a method that receives POSTs (later I will be using the other verbs too).
I have an Action Method on my RoutingRuleController:
I then have the following Route declared:
(ResourceResponse is our implementation of HAL compatible objects)
When I use hyprlinkr to generate a link to this method:
it generates:
when really it should be:
(the documented naming convention in my HAL link relations indicate that this should be a POST of the RoutingRule resource, so that is how we communicate to the client the correct method to use).
In this case, any param that is decorated with [FromBody] should not be included in the generated Uri
Is the library only intended for linking to GET methods?
BTW, it also feels weird doing:
But if I do:
I get NullRefException. Is HyprLinkr invoking the controller method?