Recommended way to get at IRequest from Razor Partial View?

What would be the recommended way to get at ServiceStack.Web.IRequest from a ASP.NET Core Razor Partial View that is nested?

Placing @inherits ViewPage<T> or @inherits ViewPage at the top of the Partial Views seems to work except for one caveat, but not sure if it is the recommended way.

The one caveat of @inherits ViewPage<T> or ViewPage is that we cannot html inline @Request. e.g. <p>@Request.SomeMethod()</p>. A CompilationFailedException error occurs.

Instead we need to define a variable up top in the @{ } and set it and then use that variable in the html.

Note: I see that we can get to Context.Request and Html.ViewContext.HttpContext.Request from the View Partial.

Go with the simplest solution you’ve found that works. There’s basically no methods on IRequest so I’m assuming the issue is due to referencing an extension method directly, but if you can reference it within a @{ .. } code block go with that.