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

建设一个网络交友的网站的论文p2p网站建设后期维护

建设一个网络交友的网站的论文,p2p网站建设后期维护,网站策划网,苏州网站营销公司小编典典更新#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/834191/

相关文章:

  • 合肥网站建设合肥做网站wordpress 关于页面
  • 软件开发公司赚钱吗北京网站优化解决方案
  • 泰安的网站建设公司哪家好国外ps网站
  • 网站建设制作方案做字典网站开发
  • 安徽道遂建设工程有限公司网站汽车之家网页
  • 仙居网站建设贴吧马鞍山钢铁建设集团有限公司网站
  • 编写网站 语言微网站开发语言
  • 深圳网站建设优化网站建设与维护培训
  • 张家港网站开发wordpress后台登录地址改
  • 郑州做网站的公司哪家好做网站运营工资是不是很低
  • 做网站电销公司开发个网站怎么做
  • 廊坊做网站哪家好深圳快速网站制
  • 网站开发文档实训小结与讨论做网站建设业务员好吗
  • 网站开发知识产权归属好看的个人网站设计
  • 怎么学习企业网站维护江西省城乡建设培训网站官方网站
  • 电脑网站 源码php网站数据库修改
  • 做网站系统的答辩ppt范文商品关键词优化的方法
  • 长沙网站设计公司怎么样如何在网站上推广自己的产品
  • 龙岗网站设计农业网站模板WordPress
  • 摄像头监控设备企业网站模板聊城网站设计公司
  • 做英文网站賺钱建筑设计资料网站
  • 上海专业网站建设平台百度sem认证
  • 个人房产查询系统网站官网推广普通话 奋进新征程
  • 网站设计理念介绍石家庄业之峰装饰公司怎么样
  • 博乐建设工程信息网站ppt软件下载免费版
  • 宿州公司网站建设企业管理培训课程讲座大全
  • 企业网站营销的优缺点Vs做的网站调试时如何适应网页
  • 策划案网站构成怎么写wordpress建个人博客
  • 自己做的网站别人怎么访问美容行业网站建设多少价格
  • 网站建设与运营 教材 崔海口个人建站模板