gpt4 book ai didi

redirect - Umbraco - 从登录重定向到上一个当前页面

转载 作者:行者123 更新时间:2023-12-01 14:36:15 25 4
gpt4 key购买 nike

我在 Umbraco 工作,目前正在使用此代码:

@if(Members.GetCurrentLoginStatus().IsLoggedIn) { 
Response.Redirect(Request.UrlReferrer.AbsolutePath);
}

在我的登录模板中,当我点击一个 protected 页面时,我将被重定向到登录(有效),然后在成功登录后被重定向回 protected 页面。这就像一个魅力,但如果我在主页上并单击“登录”并登录,我在重定向时会遇到这个问题:

Server Error in '/' Application. "Object reference not set to an instance of an object. @if(Members.GetCurrentLoginStatus().IsLoggedIn) {Response.Redirect(Request.UrlReferrer.AbsolutePath);}"

我没有使用 Visual Studio,仅使用 CMS 本身在线,因此我无法访问任何 Controller 并自行完成。

有什么办法可以解决这个问题吗?

最佳答案

好吧,如果没有引荐来源网址,它不应该重定向,对吧?那么应该做这样的事情吗?

@if(Members.GetCurrentLoginStatus().IsLoggedIn && Request.UrlReferrer != null) { 
Response.Redirect(Request.UrlReferrer.AbsolutePath);
}

关于redirect - Umbraco - 从登录重定向到上一个当前页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33038456/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com