Skip to content
This repository was archived by the owner on Apr 10, 2025. It is now read-only.

Commit 174fb12

Browse files
committed
Adds logout button to samples
1 parent 968aa85 commit 174fb12

File tree

6 files changed

+36
-0
lines changed

6 files changed

+36
-0
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
@page
2+
@model AspNetCore.IdpSample.Pages.Logout
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
using System.Threading.Tasks;
2+
using Microsoft.AspNetCore.Authentication;
3+
using Microsoft.AspNetCore.Mvc;
4+
using Microsoft.AspNetCore.Mvc.RazorPages;
5+
6+
namespace AspNetCore.IdpSample.Pages;
7+
8+
public class Logout : PageModel
9+
{
10+
public async Task<IActionResult> OnGetAsync()
11+
{
12+
await HttpContext.SignOutAsync();
13+
return Redirect("/");
14+
}
15+
}

src/AspNetCore.IdpSample/Pages/Shared/_Layout.cshtml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
<span class="navbar-text">
4444
@(Context.User.FindFirst(System.Security.Claims.ClaimTypes.NameIdentifier)?.Value ?? "")
4545
</span>
46+
<a class="nav-link text-dark" asp-area="" asp-page="/Logout">Logout</a>
4647
}
4748
</div>
4849
</div>
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
@page
2+
@model AspNetCore.SpSample.Pages.Logout
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
using System.Threading.Tasks;
2+
using Microsoft.AspNetCore.Authentication;
3+
using Microsoft.AspNetCore.Mvc;
4+
using Microsoft.AspNetCore.Mvc.RazorPages;
5+
6+
namespace AspNetCore.SpSample.Pages;
7+
8+
public class Logout : PageModel
9+
{
10+
public async Task<IActionResult> OnGetAsync()
11+
{
12+
await HttpContext.SignOutAsync();
13+
return Redirect("/");
14+
}
15+
}

src/AspNetCore.SpSample/Pages/Shared/_Layout.cshtml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
<span class="navbar-text">
4444
@(Context.User.FindFirst(System.Security.Claims.ClaimTypes.NameIdentifier)?.Value ?? "")
4545
</span>
46+
<a class="nav-link text-dark" asp-area="" asp-page="/Logout">Logout</a>
4647
}
4748
</div>
4849

0 commit comments

Comments
 (0)