Skip to content

Commit fbcd9b5

Browse files
committed
Added Vary Header to solve back navigation issue with htmx;
1 parent 95c3a63 commit fbcd9b5

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/Pages/_ViewStart.cshtml

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
@using Htmx
22
@{
3-
@if (!Context.Request.IsHtmx())
3+
@if (!Context.Request.IsHtmx() || Context.Request.IsHtmxHistoryRestoreRequest())
44
{
55
Layout = "_Layout";
66
}
77
else if(Context.Request.IsHtmxBoosted())
88
{
9+
Context.Response.Headers.Add("Vary", "HX-Request");
910
Layout = "_LayoutHtmxBoosted";
1011
}
1112
else
1213
{
14+
Context.Response.Headers.Add("Vary", "HX-Request");
1315
Layout = null;
1416
}
15-
}
17+
}

0 commit comments

Comments
 (0)