我只是想打电话给:
Redirect("https://www.google.com");
在使用(剃须页)的ASP.NET Core Web应用程序中。请注意,这是绝对最新的模板。
知道为什么什么也没发生?
这是我在“关于”页面的模型中的代码:
public class AboutModel : PageModel
{
public void OnGet()
{
Redirect("https://www.google.com");
}
}
您可以像这样在.cshtml文件中进行操作:
@page
@functions
{
public IActionResult OnGet()
{
return Redirect("https://www.google.com");
}
}
或者如果只是内部页面:
@page
@functions
{
public IActionResult OnGet()
{
return RedirectToPage("/SomePage", new { area = "SomeArea" });
}
}
希望这会有所帮助