I'm trying to use RedirectToAction to redirect to one of the three actions below. However RedirectToAction is redirecting to /Move/Staging?userId=12345 which results in a 404. What I'm trying to do with the RedirectToAction is that it redirects to /Move/12345/Staging.
I'm using RedirectToAction as follows
return RedirectToAction("StagingMove", "Maintenance", new { userId = model.userId});
I've configured the Actions as followed.
[HttpGet("Move/{userId?}/Staging/")]
public async Task<IActionResult> StagingMove(string userId)
{
try
{
{Snip}
return View(user );
}
catch (Exception ex)
{
this._logger.LogError(0, ex, "Move User Staging");
throw ex;
}
}
[HttpGet("Move/{userId?}/Arrival/")]
public async Task<IActionResult> StagingArrival(string userId)
{
try
{
ApplicationUser user = await this._userManager.GetUserAsync(userId);
return View(user );
}
catch (Exception ex)
{
this._logger.LogError(0, ex, "Move User Arrival");
throw ex;
}
}
[HttpGet("Move/{userId?}/Departures/")]
public async Task<IActionResult> StagingDepartures(string userId)
{
try
{
ApplicationUser user = await this._userManager.GetUserAsync(userId);
return View(user );
}
catch (Exception ex)
{
this._logger.LogError(0, ex, "Move User Departures");
throw ex;
}
}
I've looked into this and as far as I can tell it does work for when you have Move/Staging/{userId}. However, I can't get it to work in my situation with stuff behind the parameter.
question from:
https://stackoverflow.com/questions/65884062/redirecttoaction-with-parameters-in-the-path 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…