3

ServiceStack の SocialBootstrapAPI のサンプルをたどりましたが、リダイレクトがどのように接続されているかわかりません。認証されていない Secured コントローラーに移動すると、インデックス ページにリダイレクトされます。自分のアプリケーションで動作を再現できませんでした。この配線が行われている場所が見つかりませんでした - SocialBootstrapApi の web.config でそれらを見つけることができませんか?

から継承し、ベース コントローラーServiceStackController<AuthUserSession>を装着しました。[Authenticate]これは私が得るエラーです:

[NullReferenceException: Object reference not set to an instance of an object.]
   ServiceStack.ServiceInterface.SessionExtensions.SessionAs(ICacheClient cache, IHttpRequest httpReq, IHttpResponse httpRes) +90
   ServiceStack.Mvc.ServiceStackController.SessionAs() +64
   ServiceStack.Mvc.ServiceStackController`1.get_UserSession() +36
   ServiceStack.Mvc.ServiceStackController`1.get_AuthSession() +5
   ServiceStack.Mvc.ExecuteServiceStackFiltersAttribute.OnActionExecuting(ActionExecutingContext filterContext) +97

これは、AppHost.cs ファイルにあるものです。

        //Enable Authentication
        ConfigureAuth(container);

        //Register In-Memory Cache provider. 
        //For Distributed Cache Providers Use: PooledRedisClientManager, BasicRedisClientManager or see: https://github.com/ServiceStack/ServiceStack/wiki/Caching
        container.Register<ICacheClient>(new MemoryCacheClient());
        container.Register<ISessionFactory>(c => 
            new SessionFactory(c.Resolve<ICacheClient>()));

ConfigureAuth() は SocialBootstrapApi サンプルに似ています (まったく同じではありませんが、近いものです)。ここに何かが欠けているとは思いません。

では、これはどのように機能するのでしょうか。

4

2 に答える 2

4

OPリクエストごとに、コメントを回答にプロモートします。

IoCをMVCコントローラーに設定しましたか?ControllerBuilder.Current.SetControllerFactory(new FunqControllerFactory(container));

于 2012-12-11T21:20:09.887 に答える
2

この質問を見て、ServiceStack の認証で使用されるHtmlRedirect を変更する方法を確認してください。

ServiceStack UseCases のCustomAuthenticationMvcプロジェクトは、MVC での認証のみに焦点を当てているため、より便利な場合もあります。

于 2012-12-10T23:47:19.163 に答える