I have two actions in different controllers, Action1 calling Action2 view.
Is there a way to come back after seconds to Action1 to continue?
Action 1:
//POST - CREATE
[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult> Create(CreateEditInstitutionViewModel model)
{
.............................
_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));
}
Action2:
public IActionResult ShowMessagePage(string myMsg,bool isDone)
{
if(isDone)
return View(new MessageViewModel { msg=myMsg}); // i want to go back to Action1
return NotFound();
}
If you want to get the message and then go back to index after a few seconds , why you do not just finish this in action1? Because the parameters of action2 are all from action1, you can merge them together.
and the way to set the interval is to use js in ShowMessagePage View:
.NET forums are moving to a new home on Microsoft Q&A, we encourage you to go to Microsoft Q&A for .NET for posting new questions and get involved today.
Member
13 Points
36 Posts
After RedirectToAction Return Back To The Calling Method
Sep 27, 2020 08:39 PM|Amani Al|LINK
I have two actions in different controllers, Action1 calling Action2 view.
Is there a way to come back after seconds to Action1 to continue?
Action 1:
Action2:
All-Star
58254 Points
15678 Posts
Re: After RedirectToAction Return Back To The Calling Method
Sep 27, 2020 09:45 PM|bruce (sqlwork.com)|LINK
Then pass the url as a parameter to the show page. It can then redirect back to the original page.
Participant
990 Points
327 Posts
Re: After RedirectToAction Return Back To The Calling Method
Sep 28, 2020 05:51 AM|Jerry Cai|LINK
Hi,Amani Ai
If you want to get the message and then go back to index after a few seconds , why you do not just finish this in action1? Because the parameters of action2 are all from action1, you can merge them together.
and the way to set the interval is to use js in ShowMessagePage View:
Best Regards,
Jerry Cai
Member
168 Points
201 Posts
Re: After RedirectToAction Return Back To The Calling Method
Sep 28, 2020 10:28 AM|bluMarmalade|LINK
It makes little sense to do it all in the one method like you do.
If you have a message you want to display after the operation, you probaly should pass the message to the page you want to go to after.
so if you want to go to the index page, then send the message to the index page and display it there.