PowerShellRazorPage.UsePowerShellRazorPages method

Enables .cshtml + .cshtml.ps1 pairs. For a request to /Foo it will, in order:

  1. Look for Pages/Foo.cshtml
  2. If a Pages/Foo.cshtml.ps1 exists, execute it in the supplied runspace-pool
  3. Whatever the script assigns to $Model is copied to HttpContext.Items["PageModel"]

Razor pages (or a generic PwshKestrunModel) can then read that dynamic object.

public static IApplicationBuilder UsePowerShellRazorPages(this IApplicationBuilder app, 
    KestrunRunspacePoolManager pool, string? rootPath = null)
parameter description
app The WebApplication pipeline.
pool Kestrun’s shared KestrunRunspacePoolManager.
rootPath Optional root path for Razor Pages. Defaults to ‘Pages’.

Return Value

app for fluent chaining.

See Also