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.

mythz
—
2018-12-19T06:02:12Z —
#2

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.