2012-11-28 65 views
1

當我設置身份驗證功能重定向屬性時,它不會在我訪問安全頁面時應用。 例如,我將身份驗證功能設置爲重定向以使用自定義登錄頁面。ServiceStack AuthFeature.HtmlRedirect被忽略

authFeature.HtmlRedirect = "http://localhost/SimpleService/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(); 
    } 
} 

回答

7

我得到了與上面相同的問題。我發現的工作是重寫基本控制器中的LoginRedirectUrl。這對我有效。

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

非常感謝隊友。這個問題我正在去香蕉。 – coffekid