首页 > 解决方案 > RedirectToAction 后返回调用方法

问题描述

我在不同的控制器中有两个动作,Action1 调用 Action2 视图。

有没有办法在几秒钟后返回 Action1 继续?

行动一:

//POST - CREATE
        [HttpPost]
        [ValidateAntiForgeryToken]
        public async Task<IActionResult> Create(CreateEditInstitutionViewModel model)
        {
               //..........SOME CODE.............
                _db.Request.Add(request);

                await _db.SaveChangesAsync();
                return RedirectToAction("ShowMessagePage", new RouteValueDictionary(new { Controller = "MessagePage", Action = "ShowMessagePage", myMsg = "heloo", i = true }));
                //i want to comeback here to continue
                return RedirectToAction(nameof(Index)); 
                

        }

行动2:

public IActionResult ShowMessagePage(string myMsg,bool isDone)
        {
            if(isDone)
                return View(new MessageViewModel { msg=myMsg}); // i want to go back to Action1
            return NotFound();
        }

标签: c#asp.net-core

解决方案


推荐阅读