Skip to content

Commit ed726f2

Browse files
try another thing
1 parent 5ccecb1 commit ed726f2

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

EssentialCSharp.Web/Controllers/HomeController.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@ namespace EssentialCSharp.Web.Controllers;
99

1010
public class HomeController(ILogger<HomeController> logger, IWebHostEnvironment hostingEnvironment, ISiteMappingService siteMappingService, IHttpContextAccessor httpContextAccessor) : Controller
1111
{
12-
public IActionResult Index(string key)
12+
public IActionResult Index()
1313
{
14+
string? key = Request.Path.Value?.TrimStart('/');
15+
1416
// if no key (default case), then load up home page
1517
SiteMapping? siteMapping = siteMappingService.SiteMappings.Find(key);
1618

EssentialCSharp.Web/Program.cs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -167,20 +167,18 @@ private static void Main(string[] args)
167167
app.UseAuthentication();
168168
app.UseAuthorization();
169169
app.UseMiddleware<ReferralMiddleware>();
170-
170+
171171
app.Use((context, next) =>
172172
{
173173
context.Request.Scheme = "https";
174174
return next(context);
175175
});
176176

177177
app.MapRazorPages();
178-
app.MapDefaultControllerRoute();
179-
180-
app.MapControllerRoute(
181-
name: "slug",
182-
pattern: "{*key}",
183-
defaults: new { controller = "Home", action = "Index" });
178+
app.MapDefaultControllerRoute();
179+
180+
181+
app.MapFallbackToController("Index", "Home");
184182

185183
app.Run();
186184
}

0 commit comments

Comments
 (0)