ploeh / Hyprlinkr

A URI building helper library for ASP.NET Web API
MIT License
197 stars 34 forks source link

Cannot handle actions that return only Task #41

Open tmdude9586 opened 8 years ago

tmdude9586 commented 8 years ago

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);

ploeh commented 8 years ago

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.

dave-q commented 7 years ago

is this still in need of doing?

ploeh commented 7 years ago

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