DamianEdwards / RazorSlices

Lightweight Razor-based templates for ASP.NET Core without MVC, Razor Pages, or Blazor.
MIT License
337 stars 15 forks source link

Support `HttpContext` on Slices #22

Closed madeyoga closed 1 year ago

madeyoga commented 1 year ago

Support HttpContext on slices when used in the context of a request (e.g. on RazorSliceHttpResult)

DamianEdwards commented 1 year ago

I was thinking about this the other day actually. We could support it via the standard @inject HttpContext approach and just special-case properties of that type so that the context is set directly rather than via the IServiceProvider, or we could just add an HttpContext? property to the RazorSliceHttpResult base class and set it in the IResult.Execute method. I think I prefer the simplicity of the latter.