< Summary - Kestrun — Combined Coverage

Information
Class: Public.Response.Write-KrRedirectResponse
Assembly: Kestrun.PowerShell.Public
File(s): /home/runner/work/Kestrun/Kestrun/src/PowerShell/Kestrun/Public/Response/Write-KrRedirectResponse.ps1
Tag: Kestrun/Kestrun@2d87023b37eb91155071c91dd3d6a2eeb3004705
Line coverage
0%
Covered lines: 0
Uncovered lines: 3
Coverable lines: 3
Total lines: 34
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 - 01:25:22 Line coverage: 0% (0/2) Total lines: 30 Tag: Kestrun/Kestrun@07f821172e5dc3657f1be7e6818f18d6721cf38a09/04/2025 - 22:37:32 Line coverage: 0% (0/2) Total lines: 31 Tag: Kestrun/Kestrun@afb7aadc0a8a42bfa2b51ea62c8a6e2cf63faec609/12/2025 - 03:43:11 Line coverage: 0% (0/3) Total lines: 34 Tag: Kestrun/Kestrun@d160286e3020330b1eb862d66a37db2e26fc9042

Metrics

File(s)

/home/runner/work/Kestrun/Kestrun/src/PowerShell/Kestrun/Public/Response/Write-KrRedirectResponse.ps1

#LineLine coverage
 1<#
 2    .SYNOPSIS
 3        Writes a redirect response to the HTTP client.
 4    .DESCRIPTION
 5        Sets the Location header to the provided URL and optionally includes a
 6        message body describing the redirect.
 7    .PARAMETER Url
 8        The URL to redirect the client to. This should be a fully qualified URL.
 9    .PARAMETER Message
 10        An optional message to include in the response body. This can be used to provide additional context about the re
 11    .EXAMPLE
 12        Write-KrRedirectResponse -Url "https://example.com/new-page" -Message "You are being redirected to the new page.
 13        Redirects the client to "https://example.com/new-page" and includes a message in the response body.
 14    .NOTES
 15        This function is designed to be used in the context of a Kestrun server response.
 16#>
 17function Write-KrRedirectResponse {
 18    [KestrunRuntimeApi('Route')]
 19    [CmdletBinding()]
 20    param(
 21        [Parameter(Mandatory = $true)]
 22        [string]$Url,
 23        [Parameter()]
 24        [string]$Message
 25    )
 26    # Only works inside a route script block where $Context is available
 027    if ($null -ne $Context.Response) {
 28        # Call the C# method on the $Context.Response object
 029        $Context.Response.WriteRedirectResponse($Url, $Message)
 30    } else {
 031        Write-KrOutsideRouteWarning
 32    }
 33}
 34

Methods/Properties

Write-KrRedirectResponse()