Back to Practical Aspnetcore

HX-Replace-Url Response Header

projects/htmx/header-hx-replace-url/README.md

latest545 B
Original Source

HX-Replace-Url Response Header

This example demonstrates the usage of HX-Replace-Url response header to replace the current url at the browser history (doc).

We are using the nice utilities provided by the excellent Htmx package.

csharp
htmx.MapGet("/", (HttpRequest request, HttpResponse response) =>
{
    response.Htmx(x =>
    {
        x.ReplaceUrl("/get");
    });

    return Results.Content($"GET => {DateTime.UtcNow}");
});