Response.Redirect Migration

This sample demonstrates the ResponseShim that provides Web Forms-compatible Response.Redirect() in Blazor. The shim automatically strips ~/ prefixes and .aspx extensions for clean Blazor routing.


1. Basic Redirect

Call Response.Redirect(url) to navigate, just like in Web Forms. The shim wraps NavigationManager.NavigateTo().

Before (Web Forms)

Response.Redirect("/Session.aspx");

After (Blazor with BWFC)

// Same code works!
Response.Redirect("/migration/session");
Live Demo - Basic Redirect

Click the button to navigate to the Session demo page:


2. Tilde & .aspx Auto-Stripping

Response.Redirect("~/Products.aspx") automatically strips ~/ prefix and .aspx extension, producing a clean Blazor route.

Before (Web Forms)

Response.Redirect("~/Products.aspx");
// Navigates to: /Products.aspx

After (Blazor with BWFC)

// Same call, auto-cleaned
Response.Redirect("~/Products.aspx");
// Navigates to: /Products
Live Demo - Tilde & .aspx Stripping

The shim transforms the URL before navigation:

Input: ~/migration/session.aspx
After stripping: /migration/session


3. ResolveUrl for Link Generation

ResolveUrl() performs the same ~/ and .aspx stripping without navigating — useful for building URLs in markup.

Live Demo - ResolveUrl

ResolveUrl("~/Products.aspx") returns: /Products

ResolveUrl("~/migration/session.aspx") returns: /migration/session

ResolveUrl("~/images/logo.png") returns: /images/logo.png