I'm trying to determine the current domain name from within the Startup.Cs module of an ASP.NET Core 2.0 Razor pages application. The website will be bound to several different domains and I want to load the appropriate _layout/theme based on this.
I have been searching, but I can't figure out how to determine which domain was used to reach the site.
Any help would be greatly appreciated.
Thanks.
You have access to the request object if your controller inherits from Controller
public IActionResult About()
    {
        ViewData["Message"] = $"{this.Request.Scheme}://{this.Request.Host}{this.Request.PathBase}";
        return View();
    }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With