当前位置: 首页 > news >正文

大型网站开发 广州自己做的娱乐平台网站

大型网站开发 广州,自己做的娱乐平台网站,网站服务器在哪里买好,官方网站建设账务处理小编典典更新#xff1a;从2.2.2版本开始#xff0c;HttpContextAccessor将上下文保留在一个对象中(据说是为了防止请求之间的混淆)#xff0c;这会影响当前解决方案…因此#xff0c;您需要为IHttpContextAccessor(旧版本)提供以下实现并进行注册作为一个单例#xff1a;…小编典典更新从2.2.2版本开始HttpContextAccessor将上下文保留在一个对象中(据说是为了防止请求之间的混淆)这会影响当前解决方案…因此您需要为IHttpContextAccessor(旧版本)提供以下实现并进行注册作为一个单例public class HttpContextAccessor : IHttpContextAccessor{private static AsyncLocal _httpContextCurrent new AsyncLocal();HttpContext IHttpContextAccessor.HttpContext { get _httpContextCurrent.Value; set _httpContextCurrent.Value value; }}using Microsoft.AspNetCore.Html;using Microsoft.AspNetCore.Http;using Microsoft.AspNetCore.Mvc.Infrastructure;using Microsoft.AspNetCore.Routing;using Microsoft.Extensions.DependencyInjection;using System;using System.IO;using System.Threading.Tasks;namespace Microsoft.AspNetCore.Mvc.Rendering{public static class HtmlHelperViewExtensions{public static IHtmlContent Action(this IHtmlHelper helper, string action, object parameters null){var controller (string)helper.ViewContext.RouteData.Values[controller];return Action(helper, action, controller, parameters);}public static IHtmlContent Action(this IHtmlHelper helper, string action, string controller, object parameters null){var area (string)helper.ViewContext.RouteData.Values[area];return Action(helper, action, controller, area, parameters);}public static IHtmlContent Action(this IHtmlHelper helper, string action, string controller, string area, object parameters null){if (action null)throw new ArgumentNullException(action);if (controller null)throw new ArgumentNullException(controller);var task RenderActionAsync(helper, action, controller, area, parameters);return task.Result;}private static async Task RenderActionAsync(this IHtmlHelper helper, string action, string controller, string area, object parameters null){// fetching required services for invocationvar serviceProvider helper.ViewContext.HttpContext.RequestServices;var actionContextAccessor helper.ViewContext.HttpContext.RequestServices.GetRequiredService();var httpContextAccessor helper.ViewContext.HttpContext.RequestServices.GetRequiredService();var actionSelector serviceProvider.GetRequiredService();// creating new action invocation contextvar routeData new RouteData();foreach (var router in helper.ViewContext.RouteData.Routers){routeData.PushState(router, null, null);}routeData.PushState(null, new RouteValueDictionary(new { controller controller, action action, area area }), null);routeData.PushState(null, new RouteValueDictionary(parameters ?? new { }), null);//get the actiondescriptorRouteContext routeContext new RouteContext(helper.ViewContext.HttpContext) { RouteData routeData };var candidates actionSelector.SelectCandidates(routeContext);var actionDescriptor actionSelector.SelectBestCandidate(routeContext, candidates);var originalActionContext actionContextAccessor.ActionContext;var originalhttpContext httpContextAccessor.HttpContext;try{var newHttpContext serviceProvider.GetRequiredService().Create(helper.ViewContext.HttpContext.Features);if (newHttpContext.Items.ContainsKey(typeof(IUrlHelper))){newHttpContext.Items.Remove(typeof(IUrlHelper));}newHttpContext.Response.Body new MemoryStream();var actionContext new ActionContext(newHttpContext, routeData, actionDescriptor);actionContextAccessor.ActionContext actionContext;var invoker serviceProvider.GetRequiredService().CreateInvoker(actionContext);await invoker.InvokeAsync();newHttpContext.Response.Body.Position 0;using (var reader new StreamReader(newHttpContext.Response.Body)){return new HtmlString(reader.ReadToEnd());}}catch (Exception ex){return new HtmlString(ex.Message);}finally{actionContextAccessor.ActionContext originalActionContext;httpContextAccessor.HttpContext originalhttpContext;if (helper.ViewContext.HttpContext.Items.ContainsKey(typeof(IUrlHelper))){helper.ViewContext.HttpContext.Items.Remove(typeof(IUrlHelper));}}}}}它基于白羊座的反应。我更正了2.0版未编译的内容并添加了一些调整。当前的httpcontext和当前的actioncontext有2个美化的静态值。在httpcontext中IHttpContextFactory.Create设置了一个在代码中设置了actioncontext。请注意这取决于你使用的功能IActionContextAccessor并IHttpContextAccessor可能不会被默认注册所以你可能需要将其添加在启动services.AddSingleton();services.AddSingleton();HttpContext只是一个包装器HttpContext.Features因此如果您在其中一个进行更改则在另一个中也进行更改…我将在try/ catch的最后部分重设我所了解的内容。我IUrlHelper从Items缓存中删除了因为即使构建urlHelper的actionContext不同该值也将被重用IUrlHelperFactory.GetUrlHelper。Asp.net Core 2.0假设您不会这样做那么很有可能还有其他缓存的东西因此我建议在使用此方法时要格外小心如果不需要请不要这样做。2020-05-19
http://www.zqtcl.cn/news/952251/

相关文章:

  • 企业网站功能怎么设计wordpress文章图片轮播
  • 网站后台登陆验证码不对阳江房产网楼市数据
  • 营销型网站建设遨龙仙居住房和城乡建设规划局网站
  • 中国做视频网站有哪些淘宝做详情页代码网站
  • 网站开发一般多钱在网站设计公司上班好吗
  • 餐饮连锁企业网站建设方案北京软件研发公司
  • 外国网站架构新闻稿
  • 营销网站建设企划案例友情链接怎么添加
  • seo网站搜索优化目前好的推广平台
  • 快速搭建网站页面黄页88网免费发布信息
  • 做网站能赚吗网址大全查询ip地址
  • html5网站正在建设中商城网站系统
  • 室内设计网课北京网站优化前景
  • 北京 网站建设 知乎上海公司买新能源车
  • 成都微网站wordpress 购买
  • 网站开发一般要用到哪些软件软件开发工程师机构
  • dj网站开发建设网站备案 换空间
  • 网站建设哪家最好网站开发怎么报价
  • app 微商城网站建设网站建设流程百科
  • 网站短期培训学校小说网站怎么建设的
  • 最简单的免费网站制作模板电子商务 网站系统
  • 网站域名备案授权书网站建设长春
  • 网站维护主要从哪几个方面做seo营销的概念
  • 北京网站建设营销网站策划案4500
  • 网站建设售后培训wordpress 过滤html
  • 湖北森泰建设集团有限公司网站国外产品设计网站推荐
  • 网站建设与代运营产品介绍排版网页设计教程
  • 音乐网站排名搜索引擎网络推广方法
  • asp.net 企业网站昆明高端seo怎么做
  • 图书馆网站建设需求方案企业网站背景图片