且构网

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

如何重定向Asp.Net MVC5到RETURNURL工作

更新时间:2021-08-17 22:13:19

您需要检查URL是当地确实用这个方法(它不是由框架自动处理):http://msdn.microsoft.com/en-us/library/system.web.mvc.urlhelper.islocalurl%28v=vs.118%29.aspx

You need to check if the url is local indeed using this method (it is not handled by the framework automatically): http://msdn.microsoft.com/en-us/library/system.web.mvc.urlhelper.islocalurl%28v=vs.118%29.aspx

if (!string.IsNullOrEmpty(returnUrl) && Url.IsLocalUrl(returnUrl))
{
  return Redirect(returnUrl);
}