使用Redirect跳轉


實現方法

[HttpGet("/Redirect")]
public IActionResult Redirect(string url, string title = null, bool sucess = true) {
    ViewRedirect model = new ViewRedirect();
    model.Url = url.IsNullOrEmpty() ? "/Index" : url;
   
    model.IsSucess = sucess;
    if (model.IsSucess) {
        model.Title = title.IsNullOrEmpty() ? "操作成功" : title;
    }else {
        model.Title = title.IsNullOrEmpty() ? "操作失敗" : title;
    }
    return View(model);
}

 示例:

  url = $@"/Redirect?url={url}&title=會員注冊成功";
  return Redirect(url);

 顯示效果


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM