< Summary - Kestrun — Combined Coverage

Information
Class: Public.Razor.Add-KrPowerShellRazorPagesRuntime
Assembly: Kestrun.PowerShell.Public
File(s): /home/runner/work/Kestrun/Kestrun/src/PowerShell/Kestrun/Public/Razor/Add-KrPowerShellRazorPagesRuntime.ps1
Tag: Kestrun/Kestrun@0d738bf294e6281b936d031e1979d928007495ff
Line coverage
0%
Covered lines: 0
Uncovered lines: 6
Coverable lines: 6
Total lines: 58
Line coverage: 0%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Coverage history

Coverage history 0 25 50 75 100 08/26/2025 - 14:53:17 Line coverage: 0% (0/6) Total lines: 52 Tag: Kestrun/Kestrun@78d1e497d8ba989d121b57aa39aa3c6b22de743109/04/2025 - 22:37:32 Line coverage: 0% (0/6) Total lines: 53 Tag: Kestrun/Kestrun@afb7aadc0a8a42bfa2b51ea62c8a6e2cf63faec609/08/2025 - 20:34:03 Line coverage: 0% (0/8) Total lines: 58 Tag: Kestrun/Kestrun@3790ee5884494a7a2a829344a47743e0bf492e7210/13/2025 - 16:52:37 Line coverage: 0% (0/6) Total lines: 54 Tag: Kestrun/Kestrun@10d476bee71c71ad215bb8ab59f219887b5b4a5e12/18/2025 - 21:41:58 Line coverage: 0% (0/6) Total lines: 58 Tag: Kestrun/Kestrun@0d738bf294e6281b936d031e1979d928007495ff

Metrics

File(s)

/home/runner/work/Kestrun/Kestrun/src/PowerShell/Kestrun/Public/Razor/Add-KrPowerShellRazorPagesRuntime.ps1

#LineLine coverage
 1<#
 2.SYNOPSIS
 3    Adds PowerShell support for Razor Pages.
 4.DESCRIPTION
 5    This cmdlet allows you to register Razor Pages with PowerShell support in the Kestrun server.
 6    It can be used to serve dynamic web pages using Razor syntax with PowerShell code blocks.
 7.PARAMETER Server
 8    The Kestrun server instance to which the PowerShell Razor Pages service will be added.
 9.PARAMETER RootPath
 10    The root directory for the Razor Pages. If not specified, the default 'Pages' directory under the content root will 
 11.PARAMETER PathPrefix
 12    An optional path prefix for the Razor Pages. If specified, the Razor Pages will be served under this path.
 13.PARAMETER PassThru
 14    If specified, the cmdlet will return the modified server instance.
 15.EXAMPLE
 16    $server | Add-KrPowerShellRazorPagesRuntime -PathPrefix '/pages'
 17    This example adds PowerShell support for Razor Pages to the server, with a path prefix of '/pages'.
 18.EXAMPLE
 19    $server | Add-KrPowerShellRazorPagesRuntime
 20    This example adds PowerShell support for Razor Pages to the server without a path prefix.
 21.NOTES
 22    This cmdlet is used to register Razor Pages with PowerShell support in the Kestrun server, allowing you to serve dyn
 23#>
 24function Add-KrPowerShellRazorPagesRuntime {
 25    [KestrunRuntimeApi('Definition')]
 26    [CmdletBinding()]
 27    [OutputType([Kestrun.Hosting.KestrunHost])]
 28    param(
 29        [Parameter(Mandatory = $false, ValueFromPipeline = $true)]
 30        [Kestrun.Hosting.KestrunHost]$Server,
 31
 32        [Parameter()]
 33        [string]$RootPath = $null,
 34
 35        [Parameter()]
 36        [string]$PathPrefix = $null,
 37
 38        [Parameter()]
 39        [switch]$PassThru
 40    )
 41    begin {
 42        # Ensure the server instance is resolved
 043        $Server = Resolve-KestrunServer -Server $Server
 44    }
 45    process {
 046        if (-not ([string]::IsNullOrEmpty($RootPath))) {
 047            $RootPath = (Resolve-KrPath -Path $RootPath)
 48        }
 49        # Add PowerShell support for Razor Pages with a path prefix
 050        $Server.AddPowerShellRazorPages($RootPath, $PathPrefix) | Out-Null
 51
 052        if ($PassThru.IsPresent) {
 53            # if the PassThru switch is specified, return the modified server instance
 054            return $Server
 55        }
 56    }
 57}
 58