public static ServiceCollection GetServiceCollectionWithContextAccessor()
 {
     var services = new ServiceCollection();
     IHttpContextAccessor contextAccessor = new HttpContextAccessor();
     services.AddInstance<IHttpContextAccessor>(contextAccessor);
     return services;
 }
コード例 #2
0
ファイル: AdapterExtensions.cs プロジェクト: taori/AjaxHub
        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);
        }