Skip to content

Commit 705911f

Browse files
try another thing
1 parent 563613b commit 705911f

2 files changed

Lines changed: 7 additions & 13 deletions

File tree

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: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -167,20 +167,12 @@ private static void Main(string[] args)
167167
app.UseAuthentication();
168168
app.UseAuthorization();
169169
app.UseMiddleware<ReferralMiddleware>();
170-
171-
app.Use((context, next) =>
172-
{
173-
context.Request.Scheme = "https";
174-
return next(context);
175-
});
176170

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

185177
app.Run();
186178
}

0 commit comments

Comments
 (0)