Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Redirect from action to another action in different controller in MVC

Tags:

asp.net-mvc

What I want to do is to redirect from an action in "A" controller to an action in "B" controller it gives me this error that it can not find this action in the target controller

I am using RedirectToAction Method any help

like image 977
Eslam Soliman Avatar asked Jan 27 '26 05:01

Eslam Soliman


2 Answers

You could try this:

return RedirectToAction("kiss", "meoghe");
// RedirectToAction("action name", "controller name"); 
// meogheController => "meoghe" is controller name

If you use ActionResult for return type on method, you must use return for RedirectToAction.

like image 199
Bao Duy Avatar answered Jan 28 '26 17:01

Bao Duy


within your A controller add this in your action

RedirectToAction(new {controller="B", action="index", id=11,variable="abc"});

that's if you want to send some parameters also ,but do not forget to have a route configured which can map the "variable" parameter as well. I think this is solved in now

like image 33
Eslam Soliman Avatar answered Jan 28 '26 18:01

Eslam Soliman



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!