Skip to content

Commit 48a69d3

Browse files
authored
fix: explicit routing on home controller (#155)
1 parent 7a1d609 commit 48a69d3

4 files changed

Lines changed: 27 additions & 24 deletions

File tree

Examples/BookingSystem.AspNetCore.IdentityServer/Custom/Account/AccountController.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ public async Task<IActionResult> Logout(LogoutInputModel model)
202202
// build a return URL so the upstream provider will redirect back
203203
// to us after the user has logged out. this allows us to then
204204
// complete our single sign-out processing.
205-
string url = Url.Action("Logout", new { logoutId = vm.LogoutId });
205+
var url = Url.Action("Logout", new { logoutId = vm.LogoutId });
206206

207207
// this triggers a redirect to the external provider for sign-out
208208
return SignOut(new AuthenticationProperties { RedirectUri = url }, vm.ExternalAuthenticationScheme);

Examples/BookingSystem.AspNetCore.IdentityServer/Custom/Home/HomeController.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// Copyright (c) Brock Allen & Dominick Baier. All rights reserved.
22
// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
33

4-
54
using IdentityServer4.Services;
65
using Microsoft.AspNetCore.Authorization;
76
using Microsoft.AspNetCore.Hosting;
@@ -27,6 +26,7 @@ public HomeController(IIdentityServerInteractionService interaction, IWebHostEnv
2726
_logger = logger;
2827
}
2928

29+
[HttpGet("")]
3030
public IActionResult Index()
3131
{
3232
if (_environment.IsDevelopment())
@@ -35,18 +35,19 @@ public IActionResult Index()
3535
return View();
3636
}
3737

38-
_logger.LogInformation("Homepage is disabled in production. Returning 404.");
38+
_logger.LogInformation("Homepage is disabled in production - returning 404");
3939
return NotFound();
4040
}
4141

4242
/// <summary>
4343
/// Shows the error page
4444
/// </summary>
45+
[HttpGet("/error")]
4546
public async Task<IActionResult> Error(string errorId)
4647
{
4748
var vm = new ErrorViewModel();
4849

49-
// retrieve error details from identityserver
50+
// retrieve error details from identity server
5051
var message = await _interaction.GetErrorContextAsync(errorId);
5152
if (message != null)
5253
{

Examples/BookingSystem.AspNetCore.IdentityServer/Startup.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ public void Configure(IApplicationBuilder app)
5050
{
5151
app.UseDeveloperExceptionPage();
5252
}
53+
else
54+
{
55+
app.UseExceptionHandler("/error");
56+
}
5357

5458
app.UseIdentityServer();
5559

Examples/BookingSystem.AspNetCore.IdentityServer/Views/Shared/Error.cshtml

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
@{
44
var error = Model?.Error?.Error;
55
var errorDescription = Model?.Error?.ErrorDescription;
6-
var request_id = Model?.Error?.RequestId;
6+
var requestId = Model?.Error?.RequestId;
77
}
88

99
<div class="error-page">
@@ -12,29 +12,27 @@
1212
</div>
1313

1414
<div class="row">
15-
<div class="col-sm-6">
16-
<div class="alert alert-danger">
17-
Sorry, there was an error
15+
<div class="alert alert-danger">
16+
Sorry, there was an error
1817

19-
@if (error != null)
20-
{
21-
<strong>
22-
<em>
23-
: @error
24-
</em>
25-
</strong>
18+
@if (error != null)
19+
{
20+
<strong>
21+
<em>
22+
: @error
23+
</em>
24+
</strong>
2625

27-
if (errorDescription != null)
28-
{
29-
<div>@errorDescription</div>
30-
}
26+
if (errorDescription != null)
27+
{
28+
<div>@errorDescription</div>
3129
}
32-
</div>
33-
34-
@if (request_id != null)
35-
{
36-
<div class="request-id">Request Id: @request_id</div>
3730
}
3831
</div>
32+
33+
@if (requestId != null)
34+
{
35+
<div class="request-id">Request Id: @requestId</div>
36+
}
3937
</div>
4038
</div>

0 commit comments

Comments
 (0)