Hyprlinkr icon indicating copy to clipboard operation
Hyprlinkr copied to clipboard

Cannot handle actions that return only Task

Open tmdude9586 opened this issue 8 years ago • 3 comments

I have a controller action which has the following signature

public async Task Delete(int id);

it returns Task so that the webapi will return a 204 No Content by default. However the RouteLinker.GetUriAsync is type parameterized and expects the 2nd argument to be a parameterized Task.

errormessage

I think there should be a non generic version of the method that has the following signature:

public Task<Uri> GetUriAsync<T>(Expression<Func<T, Task>> method);

tmdude9586 avatar Sep 22 '16 13:09 tmdude9586

That sounds like a reasonable addition.

As a workaround, could you return this.StatusCode(HttpStatusCode.NoContent)? AFAICT, this would achieve the same result, while keeping the return value of your method Task<IHttpActionResult>.

All that said, I'd recommend avoiding 204 responses.

ploeh avatar Sep 23 '16 07:09 ploeh

is this still in need of doing?

dave-q avatar Oct 16 '17 22:10 dave-q

Yes, I think I'd have closed the issue if this was resolved.

ploeh avatar Oct 17 '17 11:10 ploeh