What are the ways to invoke an action in a controller? RRS feed

  • Question

  • User1922541779 posted

    I was asked this question in interview.Later  I found only one way: 

    var controller = DependencyResolver.Current.GetService<ControllerB>();
    controller.ControllerContext = new ControllerContext(this.Request.RequestContext, controller);

    from Stack overflow. Are there more ways? Also I need scenario for calling another controller action. Please help.

    Saturday, September 28, 2019 3:20 PM

All replies

  • User475983607 posted

    Pretty standard stuff that covered in most getting started tutorials. A link (GET) and an HTML form with a button (POST) are the standard methods.  There's also JavaScript XHR request libraries (AJAX, fetch) and C# libraries like the HttpClient.

    Saturday, September 28, 2019 4:43 PM