1

Is there a way to write a method in a class in a Asp.Net mvc application that (will be called from a controller and) redirects to a action and also supplies a parameter. Something like.

 public class someClass
    {
        public object Redirect(string action, string controller)
        {
            //some code
            return RedirectToAction(action, controller new {parameter=xxx});
        }
    }`

Thanks

`

  • Does this answer your question? [RedirectToAction with parameter](https://stackoverflow.com/questions/1257482/redirecttoaction-with-parameter) – DCCoder Nov 04 '20 at 16:27

1 Answers1

0

Try inheriting the Controller class as

public class SomeClass : Controller
{
  public object Redirect(string action, string controller)
        {
            //some code
            return RedirectToAction(action, controller new {parameter=xxx});
        }
}

Though, by inheriting this class though you make your class a controller

Utsavkumar Lal
  • 109
  • 1
  • 10