How access ViewContext from helper/service, @injected via ViewImports
问题 I'm writing helper class and inject in in _ViewImports with @inject HtmlHelperInject.TestHelper TestHelper And register in Startup.ConfigureServices with services.AddTransient<TestHelper>(); How can I obtain ViewContext in this helper class? I tried injecting via controler - not working, via [ViewContext] attribute on property - not working. 回答1: As of right now (beta8) the way to do this is to implement... wait for it... ICanHasViewContext . This interface adds the following contract: void