使用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