Hi I have two controllers with their action methods and views. First controller is:
[Authorize]
public class CarController : Controller
{
private readonly ICarService carService;
public EventController(ICarService carService)
{
this.carService= carService;
}
public IActionResult Create()
=> View();
[HttpPost]
public async Task<IActionResult> Create(CarFormModel carFormModel)
{
if (!ModelState.IsValid)
{
return View(carFormModel);
}
var resultId = await this.eventService
.CreateEventAsync(carFormModel);
TempData["EventId"] = resultId;
return RedirectToAction("Create","Manager");
}
and my other controller:
[Authorize]
public class ManagerController : Controller
{
private readonly IManagerService managerService;
public ManagerController(IManagerService managerService)
=> this.managerService= managerService;
public IActionResult Create()
=> View();
[HttpPost]
public async Task<IActionResult> Create(ManagerCreateModel managerCreateModel)
{
var created = await this.managerService
.CreateManagerAsync(managerCreateModel);
if (!created)
{
return View(routeCreateModel);
}
return View("All");
}
If I create car successfully Create action of Car controller is supposed to redirect me to create action of ManagerController(GET method/first one/) but instead of that it redirects me to the second one(POST method). Both controllers have their respective views in their folders. How to redirect to the get method of ManagerController?
change the action name
and redirect