I need an UrlHelper in my webapi vNext controller, so I am trying to get it injected using the constructor:

public BaseApiController(UrlHelper urlHelper)

In my Startup.cs I've added:

services.AddTransient<UrlHelper, UrlHelper>();

But when I run it, it errors because it can't resolve the ActionContext parameter to instantiate the UrlHelper. So I added:

services.AddTransient<ActionContext, ActionContext>();

But then I get the error:

A circular dependency was detected for the service of type
'Microsoft.AspNet.Mvc.ActionContext'

Any suggestions?

Related posts

Recent Viewed