ASP.NET Core中,可以使用RedirectToPage
或RedirectToAction
方法将Index.cshtml重定向到目录。以下是两种解决方法的示例代码:
RedirectToPage
方法重定向到目录:public IActionResult OnGet()
{
return RedirectToPage("/Pages/YourDirectory/Index");
}
RedirectToAction
方法重定向到目录:public IActionResult OnGet()
{
return RedirectToAction("Index", "YourDirectory");
}
请注意,上述示例中的YourDirectory
应替换为实际的目录名称。
上一篇:ASP.NET Core ILogger 只有在附加了调试器时才会记录到 Trace。
下一篇:ASP.NET Core InvalidOperationException: 尝试激活UserStore时无法解析类型DbContext的服务。