Skip to content
This repository has been archived by the owner on Dec 14, 2022. It is now read-only.

Missing information on Context in Razor #55

Closed
dawidkowal opened this issue Apr 7, 2021 · 0 comments
Closed

Missing information on Context in Razor #55

dawidkowal opened this issue Apr 7, 2021 · 0 comments

Comments

@dawidkowal
Copy link

DefaultHttpContext holds empty HttpContext.Request information.
could you add it ?

services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();

IHttpContextAccessor _httpContextAccessor;

   public class RazorViewToStringRenderer : IRazorViewToStringRenderer
    {
        private readonly IOptions<MvcViewOptions> _options;
        private readonly ITempDataProvider _tempDataProvider;
        private readonly IServiceProvider _serviceProvider;
        private readonly IHttpContextAccessor _httpContextAccessor;

        public RazorViewToStringRenderer(
            IOptions<MvcViewOptions> options,
            ITempDataProvider tempDataProvider,
            IHttpContextAccessor httpContextAccessor)
        {
            _options = options;
            _tempDataProvider = tempDataProvider;
            _httpContextAccessor = httpContextAccessor;
        }

        private ActionContext GetActionContext()
        {
            return new ActionContext(_httpContextAccessor.HttpContext, new RouteData(), new ActionDescriptor());
        }
    }

Razor context request parameters , schema

@{ var a = Context; }

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant