Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set a different homepage URL in ASP.NET CORE

Tags:

asp.net-core

On an ASP.NET Core project I have the following route:

public class AboutController : Controller {

  [HttpGet("about-us")]
  public IActionResult Index() => View();

}

How to make this url the default homepage of the site?

So when I access www.mydomain.com I am automatically redirected to www.mydomain.com/about-us

Is this possible in ASP.NET Core or do I need to do this on the domain DNS?

like image 286
Miguel Moura Avatar asked Oct 18 '22 01:10

Miguel Moura


1 Answers

You may add a redirect rule using the URL Rewriting Middleware:

var option = new RewriteOptions();
option.AddRedirect("^$", "about-us");

app.UseRewriter(option);
like image 144
Set Avatar answered Oct 21 '22 03:10

Set