使用Redirect跳转

Posted ZKCloud

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了使用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);

 显示效果

以上是关于使用Redirect跳转的主要内容,如果未能解决你的问题,请参考以下文章