当我在我的asp .net核心项目中使用RedirectToAction方法时,My Url链接转到http://localhost:2468/Passage/Details%3FpassageId%3D1
它应该是http://localhost:2468/Passage/Details?passageId=1
我该怎么解决呢
_ statisticsAppService.UpNumPlus(passageId);
return RedirectToAction("Details?passageId = " + passageId,"Passage");
您正在使用RedirectToAction
方法错误。您应该将路由值作为单独的参数传递,RedirectToAction
方法将为您构建查询字符串。
使用this overload的RedirectToAction
protected internal RedirectToRouteResult RedirectToAction(
string actionName,
string controllerName,
object routeValues
)
所以你的代码应该是
int passageId = 1; // Some passageId value you have
return RedirectToAction("Details","Passage", new { passageId = passageId });