我已遵循 SocialBootstrapAPi for ServiceStack 中的示例,但我不明白重定向是如何连接的。当我进入未经身份验证的安全控制器时,我会被重定向回索引页面。我无法在我自己的应用程序中复制该行为。未找到此接线的位置 - 在 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 示例类似(不完全相同,但很接近) - 我认为这里没有遗漏什么。
那么这是如何运作的呢?
根据 OP 的要求,将评论提升为答案:
您是否为 MVC 控制器设置了 IoC?ControllerBuilder.Current.SetControllerFactory(new FunqControllerFactory(container));
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)