且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

ASP.Net Core MVC RedirectToAction将控制器名称附加在returnUrl之前

更新时间:2023-02-24 22:54:35

如果已经具有完整的URL,则应返回Redirect.当前,您正在执行RedirectToAction,它将尝试重定向到当前控制器(Auth)下的操作.

When you have a full URL already, you should return a Redirect. Currently you are doing a RedirectToAction which will try to redirect to an action under the current controller (Auth).

if (signInResult.Succeeded)
{
   if (string.IsNullOrWhiteSpace(returnUrl))
   {
      return RedirectToAction("Timesheets", "App");
   }
   else
   {
      return Redirect(returnUrl);
   }
}