从当前视图获取 currentUrl 并将其传递给控制器​​,以在控制器中进行一些逻辑处理后将用户重定向回他来自的 URL

get currentUrl from current view and pass it to controller to redirect user back to the URL he comes from after making some logic in controller

如何将 ReturnUrl 从 View 传递到以下控制器,使用 Asp.MVc.Core.6

 public IActionResult SetLanguage(string culture, string returnUrl)
{
   
    var _returnUrl = returnUrl;

    Response.Cookies.Append(
        CookieRequestCultureProvider.DefaultCookieName,
        CookieRequestCultureProvider.MakeCookieValue(new RequestCulture(culture)),
        new CookieOptions {Expires = DateTimeOffset.UtcNow.AddYears(1)}
    );

    if (Url.IsLocalUrl(returnUrl))
    {
        return Redirect(returnUrl);
        return LocalRedirect(_returnUrl);
    }
    else
    {
        return RedirectToAction("Index", "Home");
    }
    }

风景

您可以简单地使用

asp-route-returnUrl="@Context.Request.Path"

它会成功的