Skip to content

Ensure SessionAttribute defaults to same behavior as 1.2 #463

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public SessionBehavior Behavior
}
}

public SessionStateBehavior SessionBehavior { get; set; }
public SessionStateBehavior SessionBehavior { get; set; } = SessionStateBehavior.Required;

public bool IsPreLoad { get; set; } = true;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public async Task TestSetSessionStateBehavior(string endpoint, string expected)

[InlineData("/disabled", "Session:null")]
[InlineData("/readonly", "ReadOnly:True")]
[InlineData("/session", "ReadOnly:False")]
[InlineData("/required", "ReadOnly:False")]
[InlineData("/default", "Session:null")]
[Theory]
Expand Down Expand Up @@ -82,6 +83,7 @@ private static async Task<string> GetAsync(string endpoint)
app.UseEndpoints(endpoints =>
{
endpoints.MapGet("/", (context) => GetSessionStatus(context));
endpoints.MapGet("/session", (context) => GetSessionStatus(context)).RequireSystemWebAdapterSession();
endpoints.MapGet("/disabled", (context) => GetSessionStatus(context)).WithMetadata(new SessionAttribute { SessionBehavior = SessionStateBehavior.Disabled });
endpoints.MapGet("/readonly", (context) => GetSessionStatus(context)).WithMetadata(new SessionAttribute { SessionBehavior = SessionStateBehavior.ReadOnly });
endpoints.MapGet("/required", (context) => GetSessionStatus(context)).WithMetadata(new SessionAttribute { SessionBehavior = SessionStateBehavior.Required });
Expand Down