• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# IHttpContextAccessor类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中IHttpContextAccessor的典型用法代码示例。如果您正苦于以下问题:C# IHttpContextAccessor类的具体用法?C# IHttpContextAccessor怎么用?C# IHttpContextAccessor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



IHttpContextAccessor类属于命名空间,在下文中一共展示了IHttpContextAccessor类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: ActionAlternatesFactory

		public ActionAlternatesFactory(IHttpContextAccessor httpContextAccessor)
		{
			_httpContextAccessor = httpContextAccessor;

			_actionAlternates = new Lazy<List<string>>(() =>
			{
				var httpContext = _httpContextAccessor.Current();

				if (httpContext == null)
				{
					return null;
				}

				var request = _httpContextAccessor.Current().Request;

				var actionSegments = new[] 
				{
					request.RequestContext.RouteData.GetRequiredString("area").Replace("-", "__").Replace(".", "_"), 
					request.RequestContext.RouteData.GetRequiredString("controller").Replace("-", "__").Replace(".", "_"), 
					request.RequestContext.RouteData.GetRequiredString("action").Replace("-", "__").Replace(".", "_")
				};

				return Enumerable.Range(1, actionSegments.Count()).Select(range => String.Join("__", actionSegments.Take(range))).ToList();
			});
		}
开发者ID:dminik,项目名称:voda_code,代码行数:25,代码来源:ActionAlternatesFactory.cs


示例2: DefaultAccessTokenProvider

 public DefaultAccessTokenProvider(IHttpContextAccessor contextAccessor,
     IOptions<DefaultImplsOptions> options,
     ILogger<DefaultAccessTokenProvider> logger) {
     _httpContext = contextAccessor.HttpContext;
     _logger = logger;
     _options = options.Value;
 }
开发者ID:xyting,项目名称:RigoFunc.Account,代码行数:7,代码来源:DefaultAccessTokenProvider.cs


示例3: FacebookSuiteService

 public FacebookSuiteService(
     IHttpContextAccessor httpContextAccessor,
     ISiteService siteService)
 {
     _httpContextAccessor = httpContextAccessor;
     _siteService = siteService;
 }
开发者ID:Lombiq,项目名称:Orchard-Facebook-Suite,代码行数:7,代码来源:FacebookSuiteService.cs


示例4: HtmlEngineFactory

 public HtmlEngineFactory(IHttpContextAccessor httpContextAccessor, ICompositeViewEngine viewEngine, ITempDataProvider tempDataProvider, IApplicationEnvironment hostingEnvironment)
 {
     _httpContextAccessor = httpContextAccessor;
     _viewEngine = viewEngine;
     _tempDataProvider = tempDataProvider;
     _hostingEnvironment = hostingEnvironment;
 }
开发者ID:PUG-IT,项目名称:06Etanche,代码行数:7,代码来源:HtmlEngineHelper.cs


示例5: AccountService

 public AccountService(IMapper mapper, IEmailSender messageService, IHttpContextAccessor accessor, IUserRepository userRepository)
 {
     _mapper = mapper;
     _messageService = messageService;
     _accessor = accessor;
     _userRepository = userRepository;
 }
开发者ID:parys,项目名称:MyLiverpool,代码行数:7,代码来源:AccountService.cs


示例6: QuestionService

 public QuestionService(HttpClientService factory, IHttpContextAccessor httpContextAccessor, ISurveysTokenService surveysTokenService)
 {
     _httpContextAccessor = httpContextAccessor;
     _httpClient = factory.GetHttpClient();
     _surveysTokenService = surveysTokenService;
     _cancellationToken = httpContextAccessor?.HttpContext?.RequestAborted ?? CancellationToken.None;
 }
开发者ID:mspnp,项目名称:multitenant-saas-guidance,代码行数:7,代码来源:QuestionService.cs


示例7: SiteThemeSelector

 public SiteThemeSelector(
     ISiteThemeService siteThemeService, 
     IHttpContextAccessor httpContextAccessor)
 {
     _siteThemeService = siteThemeService;
     _httpContextAccessor = httpContextAccessor;
 }
开发者ID:jchenga,项目名称:Orchard2,代码行数:7,代码来源:SiteThemeSelector.cs


示例8: RequestIdService

 // This service can only be instantiated by a request-scoped container
 public RequestIdService(IServiceProvider services, IHttpContextAccessor contextAccessor)
 {
     if (contextAccessor.HttpContext.RequestServices != services)
     {
         throw new InvalidOperationException();
     }
 }
开发者ID:phinq19,项目名称:git_example,代码行数:8,代码来源:RequestIdService.cs


示例9: HttpContextClientInfoProvider

        /// <summary>
        /// Creates a new <see cref="HttpContextClientInfoProvider"/>.
        /// </summary>
        public HttpContextClientInfoProvider(IHttpContextAccessor httpContextAccessor)
        {
            _httpContextAccessor = httpContextAccessor;
            _httpContext = httpContextAccessor.HttpContext;

            Logger = NullLogger.Instance;
        }
开发者ID:vytautask,项目名称:aspnetboilerplate,代码行数:10,代码来源:HttpContextClientInfoProvider.cs


示例10: ComponentTagHelper

 public ComponentTagHelper(IHttpContextAccessor contextAccessor, IBricsContextAccessor bricsContext)
 {
     _contextAccessor = contextAccessor;
     _bricsContext = bricsContext;
     _urlHelper = contextAccessor.HttpContext.RequestServices.GetService<IUrlHelper>();
     _htmlHelper = contextAccessor.HttpContext.RequestServices.GetService<IHtmlHelper>();
 }
开发者ID:marcuslindblom,项目名称:aspnet5,代码行数:7,代码来源:ComponentTagHelper.cs


示例11: GeoDataManager

 public GeoDataManager(
     IGeoRepository geoRepository,
     IHttpContextAccessor contextAccessor)
 {
     repo = geoRepository;
     _context = contextAccessor?.HttpContext;
 }
开发者ID:lespera,项目名称:cloudscribe,代码行数:7,代码来源:GeoDataManager.cs


示例12: DirectoryController

 public DirectoryController(ClientDirectoryContext context, ILoginHelper loginHelper,
     IHttpContextAccessor contextAccessor)
 {
     _context = context;
     _contextAccessor = contextAccessor;
     _loginHelper = loginHelper;
 }
开发者ID:pulsars,项目名称:webapi-client,代码行数:7,代码来源:DirectoryController.cs


示例13: AccountModule

        public AccountModule(IAccountService accountService, IHttpContextAccessor httpContextAccessor)
        {
            this.context = httpContextAccessor.Current;

            Post["/Account/Create"] = x =>
                                          {
                                              var command = new AddUserAccountCommand(Request.Form.EmailAddress,
                                                                                  Request.Form.Password,
                                                                                  uint.Parse(Request.Form.RateOutOf));
                                              var account = accountService.CreateAccount(command);

                                              var accountValidationUrl = context.Request.BaseUrl() + "/Account/Validate/" + account.Key;

                                              return Response.AsJson(new
                                                                         {
                                                                             AccountKey = account.Key,
                                                                             AccountValidationUrl = accountValidationUrl
                                                                         });
                                          };

            Post["/Account/Validate"] = x =>
                                                           {
                                                               var command = new ValidateAccountCommand(Request.Form.ValidationKey);
                                                               return Response.AsJson((int)accountService.ValidateAccount(command));
                                                           };
        }
开发者ID:cairey,项目名称:Let-Me-Rate-NancyFX,代码行数:26,代码来源:AccountModule.cs


示例14: SiteManager

        public SiteManager(
            SiteContext currentSite,
            ISiteCommands siteCommands,
            ISiteQueries siteQueries,
            IUserCommands userCommands,
            IUserQueries userQueries,
            SiteDataProtector dataProtector,
            IHttpContextAccessor contextAccessor,
            ILogger<SiteManager> logger,
            IOptions<MultiTenantOptions> multiTenantOptionsAccessor,
            IOptions<SiteConfigOptions> setupOptionsAccessor,
            CacheHelper cacheHelper
            )
        {

            commands = siteCommands;
            queries = siteQueries;
            this.userCommands = userCommands;
            this.userQueries = userQueries;
            multiTenantOptions = multiTenantOptionsAccessor.Value;
            setupOptions = setupOptionsAccessor.Value;
            _context = contextAccessor?.HttpContext;
            this.dataProtector = dataProtector;
            log = logger;

            //resolver = siteResolver;
            siteSettings = currentSite;
            this.cacheHelper = cacheHelper;
        }
开发者ID:joeaudette,项目名称:cloudscribe,代码行数:29,代码来源:SiteManager.cs


示例15: UserManager

        public UserManager(ApplicationDbContext dbContext, IHttpContextAccessor contextAccessor)
        {
            Guard.ArgumentNotNull(dbContext, nameof(dbContext));

            _dbContext = dbContext;
            _cancellationToken = contextAccessor?.HttpContext?.RequestAborted ?? CancellationToken.None;
        }
开发者ID:mspnp,项目名称:multitenant-saas-guidance,代码行数:7,代码来源:UserManager.cs


示例16: CurrentContentIdAccessor

 public CurrentContentIdAccessor(
     IHttpContextAccessor hca,
     IAliasService aliasService)
 {
     _hca = hca;
     _aliasService = aliasService;
 }
开发者ID:hqmirror,项目名称:Piedone.HelpfulLibraries,代码行数:7,代码来源:CurrentContentIdAccessor.cs


示例17: CSClassroomTelemetryInitializer

 /// <summary>
 /// Constructor.
 /// </summary>
 public CSClassroomTelemetryInitializer(
     IHttpContextAccessor httpContextAccessor,
     IActionContextAccessor actionContextAccessor)
 {
     _httpContextAccessor = httpContextAccessor;
     _actionContextAccessor = actionContextAccessor;
 }
开发者ID:CSClassroom,项目名称:CSClassroom,代码行数:10,代码来源:CSClassroomTelemetryInitializer.cs


示例18: DefaultHostEnvironment

 public DefaultHostEnvironment(IClock clock, IHttpContextAccessor httpContextAccessor)
 {
     _clock = clock;
     _httpContextAccessor = httpContextAccessor;
     T = NullLocalizer.Instance;
     Logger = NullLogger.Instance;
 }
开发者ID:gokhandisikara,项目名称:Coevery-Framework,代码行数:7,代码来源:DefaultHostEnvironment.cs


示例19: SingleFileLocationService

 public SingleFileLocationService(ILocalizationConfiguration configuration, IHttpContextAccessor httpContext)
 {
     LocalizationInstanceContainer.Instance = this;
     this.configuration = configuration;
     this.httpContext = httpContext;
     LoadResources(configuration.GetLocalizationFolderPath());
 }
开发者ID:alexou1905,项目名称:HaoLocalization,代码行数:7,代码来源:SingleFileLocationService.cs


示例20: Configure

 /// <summary>
 /// Configures the <see cref="Context"/>.
 /// </summary>
 /// <param name="environment">The environment the application is running under. This can be Development, 
 /// Staging or Production by default.</param>
 /// <param name="httpContextAccessor">The HTTP context accessor.</param>
 public static void Configure(
     IHostingEnvironment environment,
     IHttpContextAccessor httpContextAccessor)
 {
     Environment = environment;
     HttpContextAccessor = httpContextAccessor;
 }
开发者ID:vivekdhami,项目名称:ASP.NET-MVC-Boilerplate,代码行数:13,代码来源:Context.cs



注:本文中的IHttpContextAccessor类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# IHttpEntity类代码示例发布时间:2022-05-24
下一篇:
C# IHttpContext类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap