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)
parameter description
app The WebApplication pipeline.
pool Kestrun’s shared KestrunRunspacePoolManager.

Return Value

app for fluent chaining.

See Also