Bigtoe
Bigtoe

Reputation: 3520

ServiceStack AuthFeature.HtmlRedirect being ignored

When I set the authentication feature redirect property it is not being applied when I go to access a secure page. For example I set the authentication feature to redirect to use a custom log in page.

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

But if I go to a secure controller, this redirect is never being applied it always uses the service stack default of "/login". The redirect it is using does not even include the originating site name of SimpleService. Sample controller below.

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

I have also tried to override the the redirect on the Authenticate attribute, but to no avail. Has anyone any ideas what I could be doing wrong?

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

Upvotes: 1

Views: 511

Answers (1)

user1661621
user1661621

Reputation: 797

I got the same issues as above. A work around I found is to override the LoginRedirectUrl in your base controller. This worked for me.

eg

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

Upvotes: 7

Related Questions