当前位置: 首页>>代码示例>>C#>>正文


C# IHttpContextAccessor类代码示例

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


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


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