Answers:
您可以将id作为RedirectToAction()方法的routeValues参数的一部分传递。
return RedirectToAction("Action", new { id = 99 });这将导致重定向到Site / Controller / Action / 99。无需临时或任何类型的视图数据。
Return RedirectToAction("Action", "Controller", New With {.id = 99})
                    从我的研究来看,库尔特的答案应该是正确的,但是当我尝试时,我必须这样做才能使它真正为我工作:
return RedirectToAction( "Main", new RouteValueDictionary( 
    new { controller = controllerName, action = "Main", Id = Id } ) );如果我未指定控制器,则该控制器中的操作RouteValueDictionary无效。
同样,当这样编码时,第一个参数(动作)似乎也被忽略了。因此,如果仅在Dict中指定控制器,并期望第一个参数指定Action,则它也不起作用。
如果您以后要来,请先尝试Kurt的答案,如果仍然有问题,请尝试此。
controller如果重定向操作与您要重定向的操作位于同一控制器中,则该参数是可选的。
                    RedirectToAction 带有参数:
return RedirectToAction("Action","controller", new {@id=id});new {id = id}可以正常工作,因为框架知道您要指代哪个变量。
                    还值得注意的是,您可以传递多个参数。id将用于构成URL的一部分,而其他任何ID将在?之后作为参数传递。在网址中,并将其默认设置为UrlEncoded。
例如
return RedirectToAction("ACTION", "CONTROLLER", new {
           id = 99, otherParam = "Something", anotherParam = "OtherStuff" 
       });因此,网址为:
    /CONTROLLER/ACTION/99?otherParam=Something&anotherParam=OtherStuff这些可以由您的控制器引用:
public ActionResult ACTION(string id, string otherParam, string anotherParam) {
   // Your code
          }//How to use RedirectToAction in MVC
return RedirectToAction("actionName", "ControllerName", routevalue);return RedirectToAction("Index", "Home", new { id = 2});MVC 4示例...
请注意,您不必总是传递名为ID的参数
var message = model.UserName + " - thanks for taking yourtime to register on our glorious site. ";
return RedirectToAction("ThankYou", "Account", new { whatever = message });和,
public ActionResult ThankYou(string whatever) {
        ViewBag.message = whatever;
        return View();
} 当然,如果您愿意,可以将字符串分配给模型字段,而不是使用ViewBag。
如果您的参数碰巧是一个复杂的对象,则可以解决此问题。关键是RouteValueDictionary构造函数。
return RedirectToAction("Action", new RouteValueDictionary(Model))如果您碰巧有收藏集,那么它会有点棘手,但是这个其他答案很好地涵盖了这一点。
RedirectToAction("Action", "Controller" ,new { id });为我工作,不需要做 new{id = id}
我将重定向到同一控制器内,因此我不需要该控制器,"Controller"但是我不确定何时需要将控制器作为参数使用的特定逻辑。
RedirectToAction("Action", "Controller", new { id = id});正是我在Core 3.1应用程序中需要的。
                    如果要显示错误消息,[httppost]那么他/她可以尝试使用传递ID
return RedirectToAction("LogIn", "Security", new { @errorId = 1 });对于这样的细节
 public ActionResult LogIn(int? errorId)
        {
            if (errorId > 0)
            {
                ViewBag.Error = "UserName Or Password Invalid !";
            }
            return View();
        }
[Httppost]
public ActionResult LogIn(FormCollection form)
        {
            string user= form["UserId"];
            string password = form["Password"];
            if (user == "admin" && password == "123")
            {
               return RedirectToAction("Index", "Admin");
            }
            else
            {
                return RedirectToAction("LogIn", "Security", new { @errorId = 1 });
            }
}希望它能正常工作。
这可能是几年前的事,但是无论如何,这也取决于您的Global.asax地图路线,因为您可以添加或编辑参数以适合您的需要。
例如。
Global.asax
    public static void RegisterRoutes(RouteCollection routes)
    {
        routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
        routes.MapRoute(
            "Default", // Route name
            "{controller}/{action}/{id}", // URL with parameters
            //new { controller = "Home", action = "Index", id = UrlParameter.Optional 
            new { controller = "Home", action = "Index", id = UrlParameter.Optional,
                  extraParam = UrlParameter.Optional // extra parameter you might need
        });
    }那么您需要传递的参数将更改为:
return RedirectToAction( "Main", new RouteValueDictionary( 
    new { controller = controllerName, action = "Main", Id = Id, extraParam = someVariable } ) );以下是asp.net core 2.1的成功。它可能适用于其他地方。字典ControllerBase.ControllerContext.RouteData.Values可以从action方法中直接访问和写入。也许这是其他解决方案中数据的最终目的地。它还显示默认路由数据来自何处。
[Route("/to/{email?}")]
public IActionResult ToAction(string email)
{
    return View("To", email);
}
[Route("/from")]
public IActionResult FromAction()
{
    ControllerContext.RouteData.Values.Add("email", "mike@myemail.com");
    return RedirectToAction(nameof(ToAction));
         // will redirect to /to/mike@myemail.com
}
[Route("/FromAnother/{email?}")]`
public IActionResult FromAnotherAction(string email)
{
    return RedirectToAction(nameof(ToAction));
         // will redirect to /to/<whatever the email param says>
         // no need to specify the route part explicitly
}