Skip to content

How to access Cookie (and QueryString) collection ? #164

@imanabidi

Description

@imanabidi

I need to access Cookies and Query Params inside of my handler.

I found that from the official documentation about triggercontexts that there is a way of accessing some parameters of HttpContext via IContextProvider injection which works like below code and it is very handy.

internal class CallbackHttpRequestHandler : CommandHandlerBase<CallbackHttpRequestDto, IActionResult>
  {
    private readonly IContextProvider _contextProvider;
    public CallbackHttpRequestDtoHandler(IContextProvider contextProvider) : base(false)
    {
        _contextProvider = context;
    }
    protected override async Task<IActionResult> ExecuteAsync(CallbackHttpRequestDto request,   IActionResult previousResult)
    {
        if (_contextProvider.HttpContext != null)
        {
            var headers = _context.HttpContext.Headers;
            var requestUrl = _context.HttpContext.RequestUrl;
            var claimsPrincipal = _context.HttpContext.ClaimsPrincipal;
         }
    }
  }

But there is no mapping between original HttpRequest Cookies collections and I need it.

How can I achieve that? I found it not easy inside the SDK to pass this Cookies collection. Please help.

Also posted here on SO

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions