【问题标题】:ServiceStack AuthFeature.HtmlRedirect being ignoredServiceStack AuthFeature.HtmlRedirect 被忽略
【发布时间】:2012-11-28 12:02:27
【问题描述】:

当我设置身份验证功能重定向属性时,当我访问安全页面时它不会被应用。 例如,我将身份验证功能设置为重定向以使用自定义登录页面。

authFeature.HtmlRedirect = "http://localhost/SimpleService/login";

但是,如果我使用安全控制器,则永远不会应用此重定向,它始终使用 "/login" 的服务堆栈默认值。它使用的重定向甚至不包括 SimpleService 的原始站点名称。下面是示例控制器。

[Authenticate]
public class PrivateController : ControllerBase
{
    public ViewResult SecurePage()
    {
        return View();
    }
}

我也尝试覆盖 Authenticate 属性上的重定向,但无济于事。有没有人知道我可能做错了什么?

[Authenticate(HtmlRedirect = "http://localhost/SimpleService/login")]
public class PrivateController : ControllerBase
{
    public ViewResult SecurePage()
    {
        return View();
    }
}

【问题讨论】:

    标签: authentication servicestack


    【解决方案1】:

    我遇到了与上述相同的问题。我发现的一种解决方法是覆盖基本控制器中的 LoginRedirectUrl。这对我有用。

    例如

    public override string LoginRedirectUrl
    {
        get
        {
            return "/Account/Login?redirect={0}";
        }
    }
    

    【讨论】:

    • 非常感谢伙计。我对这个问题很感兴趣。
    猜你喜欢
    • 2013-07-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-09-26
    • 2016-06-05
    • 2014-02-25
    相关资源
    最近更新 更多