public static ServiceCollection GetServiceCollectionWithContextAccessor() { var services = new ServiceCollection(); IHttpContextAccessor contextAccessor = new HttpContextAccessor(); services.AddInstance<IHttpContextAccessor>(contextAccessor); return services; }
public static HtmlString RenderAjaxHubFunctions(this IHtmlHelper source) { var accessor = new HttpContextAccessor(); var uh = accessor.HttpContext.RequestServices.GetRequiredService<IUrlHelper>(); var test = uh.Action("About", "Home"); return new HtmlString(test); }