本文整理汇总了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();
});
}
示例2: DefaultAccessTokenProvider
public DefaultAccessTokenProvider(IHttpContextAccessor contextAccessor,
IOptions<DefaultImplsOptions> options,
ILogger<DefaultAccessTokenProvider> logger) {
_httpContext = contextAccessor.HttpContext;
_logger = logger;
_options = options.Value;
}
示例3: FacebookSuiteService
public FacebookSuiteService(
IHttpContextAccessor httpContextAccessor,
ISiteService siteService)
{
_httpContextAccessor = httpContextAccessor;
_siteService = siteService;
}
示例4: HtmlEngineFactory
public HtmlEngineFactory(IHttpContextAccessor httpContextAccessor, ICompositeViewEngine viewEngine, ITempDataProvider tempDataProvider, IApplicationEnvironment hostingEnvironment)
{
_httpContextAccessor = httpContextAccessor;
_viewEngine = viewEngine;
_tempDataProvider = tempDataProvider;
_hostingEnvironment = hostingEnvironment;
}
示例5: AccountService
public AccountService(IMapper mapper, IEmailSender messageService, IHttpContextAccessor accessor, IUserRepository userRepository)
{
_mapper = mapper;
_messageService = messageService;
_accessor = accessor;
_userRepository = userRepository;
}
示例6: QuestionService
public QuestionService(HttpClientService factory, IHttpContextAccessor httpContextAccessor, ISurveysTokenService surveysTokenService)
{
_httpContextAccessor = httpContextAccessor;
_httpClient = factory.GetHttpClient();
_surveysTokenService = surveysTokenService;
_cancellationToken = httpContextAccessor?.HttpContext?.RequestAborted ?? CancellationToken.None;
}
示例7: SiteThemeSelector
public SiteThemeSelector(
ISiteThemeService siteThemeService,
IHttpContextAccessor httpContextAccessor)
{
_siteThemeService = siteThemeService;
_httpContextAccessor = httpContextAccessor;
}
示例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();
}
}
示例9: HttpContextClientInfoProvider
/// <summary>
/// Creates a new <see cref="HttpContextClientInfoProvider"/>.
/// </summary>
public HttpContextClientInfoProvider(IHttpContextAccessor httpContextAccessor)
{
_httpContextAccessor = httpContextAccessor;
_httpContext = httpContextAccessor.HttpContext;
Logger = NullLogger.Instance;
}
示例10: ComponentTagHelper
public ComponentTagHelper(IHttpContextAccessor contextAccessor, IBricsContextAccessor bricsContext)
{
_contextAccessor = contextAccessor;
_bricsContext = bricsContext;
_urlHelper = contextAccessor.HttpContext.RequestServices.GetService<IUrlHelper>();
_htmlHelper = contextAccessor.HttpContext.RequestServices.GetService<IHtmlHelper>();
}
示例11: GeoDataManager
public GeoDataManager(
IGeoRepository geoRepository,
IHttpContextAccessor contextAccessor)
{
repo = geoRepository;
_context = contextAccessor?.HttpContext;
}
示例12: DirectoryController
public DirectoryController(ClientDirectoryContext context, ILoginHelper loginHelper,
IHttpContextAccessor contextAccessor)
{
_context = context;
_contextAccessor = contextAccessor;
_loginHelper = loginHelper;
}
示例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));
};
}
示例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;
}
示例15: UserManager
public UserManager(ApplicationDbContext dbContext, IHttpContextAccessor contextAccessor)
{
Guard.ArgumentNotNull(dbContext, nameof(dbContext));
_dbContext = dbContext;
_cancellationToken = contextAccessor?.HttpContext?.RequestAborted ?? CancellationToken.None;
}