I am working on a project which have scenario to redirect to httppost method from another controller which have a httpget method. Can you guys suggest me a good approach to achieve it?
Example is given below
ControllerA :
[HttpPost]
[Route("Student/InsertData", Name = "InsertData")]
[RequiredQueryStringKeys("SystemId", "IncidentDt")]
public IHttpActionResult InsertData([FromBody] StudentDetailRequest request)
{
//Code
}
Controller B:
[HttpGet]
[Route("Student/GetDetail")]
[RequiredQueryStringKeys("SystemId", "IncidentDt", "Cd")]
public IHttpActionResult GetDetail()
{
------- Need to call ControllerA POST method here
}
NOTE: My requirement is to reroute Student/GetDetail to Student/InsertData. If User hit Student/GetDetail then it should redirect to Student/InsertData.
HttpClientand making a restful call? Have you tried abstracting the business logic from theInsertDataimplementation to a service class that can be called directly?