Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
使用时有什么优势或区别...
Sitecore.Web.WebUtil.Redirect(string path)
...代替...
Response.Redirect(string url)
...用于重定向?
有一个主要区别。Sitecore 方法将检查是否确实存在HttpContext. Sitecore.Web.WebUtil.Redirect(string path)除此之外,轮流调用没有区别HttpContext.Current.Response.Redirect(path, true);
HttpContext
HttpContext.Current.Response.Redirect(path, true)
但是,如果您调用Sitecore.Web.WebUtil.Redirect(path, false)并且您提供的路径与您所在的页面相同,则不会发生重定向。
Sitecore.Web.WebUtil.Redirect(path, false)