An Azure service that provides streamlined full-stack web app development.
Hello @Andrew Sabin
Thank you for the additional details.
On Azure App Service the request path is normalized, and Blazor’s catch-all route parameter decodes the captured segments.
“Slashes and segments of the captured path are decoded. For a route template of /catch-all/{pageRoute}, the URL /catch-all/this/is/a%2Ftest%2A yields this/is/a/test.”
That’s why both redirectToURL and your HttpUtility.UrlDecode call end up with https:/… in production (while it works under the local Kestrel server).
Recommended fix – use a query string
Move the destination URL out of the path and into a query string. Query-string values are not subjected to the same path decoding/normalization.
- Update the Blazor Page
@page "/redirect" @inject NavigationManager Navigation @if (safeUrl is not null) { <div class="redirect-grid"> <!-- keep your existing warning markup here --> <h4>@safeUrl</h4> <a class="btn btn-primary" target="_blank" rel="noopener noreferrer" href="@safeUrl"> Click To Continue </a> </div> } @code { [SupplyParameterFromQuery(Name = "url")] private string? RedirectToUrl { get; set; } private string? safeUrl; protected override void OnParametersSet() { safeUrl = null; // [SupplyParameterFromQuery] already URL-decodes the value — do NOT decode again if (Uri.TryCreate(RedirectToUrl, UriKind.Absolute, out var uri) && (uri.Scheme == Uri.UriSchemeHttp || uri.Scheme == Uri.UriSchemeHttps)) { safeUrl = uri.AbsoluteUri; } else { Navigation.NotFound(); // .NET 10 helper } } }- Do not call Uri.UnescapeDataString or HttpUtility.UrlDecode again. The attribute already gives you the decoded value. A second decode will break any legitimate % sequences in the target URL.
- The scheme check (http / https only) is required. Without it, a javascript: or data: payload could be bound into the href.
Update the Link Processing service
Change the place where you currently build the redirect link to:
Do not pre-encode the value before calling EscapeDataString — that creates double-encoding and is a common follow-up problem.$"/redirect?url={Uri.EscapeDataString(originalHref)}"
This approach works consistently on Azure App Service (Linux and Windows) and locally.
Please let us know if this helps or need more assistance on this issue.
Thanks