3 Replies - 328 Views - Last Post: 23 February 2020 - 09:55 PM Rate Topic: -----

#1 ahmedba   User is offline

  • D.I.C Head

Reputation: -1
  • View blog
  • Posts: 220
  • Joined: 24-January 14

How to call actionresult on another actionresult on asp.net core 2.2 ?

Posted 11 September 2019 - 04:53 AM

Problem

How to call ActionResult on another ActionResult ?

I have two ActionResult PostUserLogins and ActionResult GetBranches

Can I call ActionResult getbranches inside ActionResult PostUserLogins ?

[
HttpPost(Contracts.ApiRoutes.Login.UserLogin)]
        public IActionResult PostUserLogins([FromBody] Users user)
        {
// call action result to get  GetBranches(Users user) as json;
        }
 [HttpGet(Contracts.ApiRoutes.Login.GetBranches)]
        public IActionResult GetBranches([FromBody] Users user)
        {
// here return json 
        }


Is This A Good Question/Topic? 0
  • +

Replies To: How to call actionresult on another actionresult on asp.net core 2.2 ?

#2 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 15507
  • View blog
  • Posts: 62,086
  • Joined: 12-June 08

Re: How to call actionresult on another actionresult on asp.net core 2.2 ?

Posted 11 September 2019 - 06:49 AM

Are you expecting to navigate to that function, or just get the results?
Was This Post Helpful? 0
  • +
  • -

#3 DarenR   User is offline

  • D.I.C Lover

Reputation: 637
  • View blog
  • Posts: 4,226
  • Joined: 12-January 10

Re: How to call actionresult on another actionresult on asp.net core 2.2 ?

Posted 11 September 2019 - 11:33 AM

i think the best way is to create a main result with partial results which will give you all the action results you want
Was This Post Helpful? 0
  • +
  • -

#4 ishan.shah   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 22
  • Joined: 28-March 19

Re: How to call actionresult on another actionresult on asp.net core 2.2 ?

Posted 23 February 2020 - 09:55 PM

How To Call Actionresult On Another Actionresult On Asp.Net Core 2.2 ?

you can call action result to another action result

with the help of return RedirectToAcion ("method name which one would you like to call ", "ControllerName");
public ActionResult abc()
{
    ViewData["OutputMessage"] = "Hello World";
    return RedirectToAction("xyz","ControllerName");
    //this will go to second method;
}


public ActionResult xyz()
{
    return View();
    //this will go to xyz as default;
}

This post has been edited by astonecipher: 24 February 2020 - 11:53 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1