GCR deployment testing in progress - content type issue still remaining.
This commit is contained in:
@@ -12,7 +12,7 @@ namespace Htmx.ApiDemo;
|
||||
/// </summary>
|
||||
public static class HtmxPageExtensions
|
||||
{
|
||||
public static void WriteHtmxPage(
|
||||
public static HtmxResult WriteHtmxPage(
|
||||
this HttpContext ctx,
|
||||
IHtmxComponent body,
|
||||
string title = "App",
|
||||
@@ -21,24 +21,20 @@ public static class HtmxPageExtensions
|
||||
{
|
||||
if (ctx.Request.Headers.ContainsKey("HX-Request"))
|
||||
{
|
||||
// Partial swap: tell HTMX to update the browser <title> tag
|
||||
ctx.Response.Headers["HX-Title"] = title;
|
||||
ctx.WriteHtmxBody(body);
|
||||
return ctx.WriteHtmxBody(body);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Resolve display name: prefer DisplayName claim, fall back to email/name
|
||||
string? userName = ctx.User.Identity?.IsAuthenticated == true
|
||||
? (ctx.User.FindFirst("DisplayName")?.Value
|
||||
?? ctx.User.FindFirst(System.Security.Claims.ClaimTypes.Name)?.Value)
|
||||
: null;
|
||||
|
||||
// Resolve antiforgery token for the logout form in the layout
|
||||
var antiforgery = ctx.RequestServices.GetRequiredService<IAntiforgery>();
|
||||
var afTokens = antiforgery.GetAndStoreTokens(ctx);
|
||||
|
||||
// Full page load: wrap in the shell layout
|
||||
ctx.WriteHtmxBody(new Templates.MainLayout(body, title, appName, pageTitle, userName, afTokens.RequestToken));
|
||||
return ctx.WriteHtmxBody(new Templates.MainLayout(body, title, appName, pageTitle, userName, afTokens.RequestToken));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user