[英]How to massage data before redirect to another web application in asp.net core 2.0
[英]Redirect to another website is not working in ASP.NET Core Web Application
我只是想打電話:
Redirect("https://www.google.com");
在 ASP.NET Core Web 應用程序中使用 (Razor Pages)。 請注意,這是絕對最新的模板。
知道為什么什么都沒有發生嗎?
這是我在“關於”頁面的模型中的代碼:
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" });
}
}
請注意,在這兩種情況下, Redirect/RedirectToPage
都作為IActionResult
返回。
希望這可以幫助
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.