我的问题是我在 PublicProfile
操作中添加了一条新路由 [HttpGet("public-profile/{avatarName}")]
但我没有知道如何重定向到此操作。
这就是我想要重定向的操作
[HttpGet("public-profile/{avatarName}")]
public async Task<ActionResult> PublicProfile(string avatarName)
{
return View();
}
我尝试过的是这样
[HttpPost]
public ActionResult PublicProfle()
{
return RedirectToAction("PublicProfile", "name");
}
但是它不起作用
我已经在这里读过它,但它对我没有帮助
RedirectToAction As Get Request format
RedirectToAction with parameter
ASP.Net Core MVC RedirectToAction is appending controller name in front of returnUrl
最佳答案
尝试
return RedirectToAction("PublicProfile", new { avatarName = "name" });
关于c# - 当我使用 [HttpGet ("public-profile/{avatarName}")] 时如何在 asp.net-core 中 RedirectToAction,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54622017/