Closed barbosatek closed 7 years ago
The AsyncController
in that example code snippet is Ploeh.Hyprlinkr.UnitTest.Controllers.AsyncController
, an example class that demonstrates how you'd get a Uri
from a Controller with an async action method: https://github.com/ploeh/Hyprlinkr/blob/master/Hyprlinkr.UnitTest/RouteLinkerTests.cs#L350-L363
Hyprlinkr only works with ASP.NET Web API.
HTH
Would this work if I only have attribute based routes? I'm not even defining the "DefaultApi" route.
var uri = await linker.GetUriAsync((DependentsV1Controller x) => x.Get(model.CompanyId, model.EmployeeId));
Seems to just hang infinetly while awaiting, deadlock?
UPDATE:
It seems it's a deadlock. If I use:
var uri = Task.Run(() => { return linker.GetUri((DependentsV1Controller x) => x.Get(model.CompanyId, model.EmployeeId)); }).Result;
instead of
Task.Factory.StartNew<Uri>((Func<Uri>) (() => this.GetUri(methodCallExp)));
I get the actual exception.
Additional information: A route named 'DefaultApi' could not be found in the route collection.
Hyprlinkr only partially works with attribute-based routes: https://github.com/ploeh/Hyprlinkr/issues/30
Closing due to inactivity.
While the following workaround works for MVC,
AsyncController
is not available on WebAPI, is there a workaround for it?Uri actual = linker.GetUriAsync((AsyncController c) => c.Get(id)).Result;