可以在某个Action方法上添加[Route("/")]特性,以避免没有默认页面
[Route("/")]
public string method1()
{
return "Hello from method1";
}
完整示例
public class HomeController
{
[Route("home")]
[Route("/")]
public string Index()
{
return "Hello from Index";
}
[Route("about")]
public string About()
{
return "Hello from About";
}
[Route("contact-us/{mobile:regex(^\\d{{10}}$)}")]
public string Contact()
{
return "Hello from Contact";
}
}