2012-08-09 36 views
0

我想獲得ServiceStacks身份驗證以在MVC網站上工作。我的控制器是這樣的:ServiceStack AuthenticateAttribute第二次導致空引用異常,除非刪除了Cookie

public abstract class ControllerBase : ServiceStackController<AuthUserSession> { 
    //TODO: override LoginRedirectUrl 
    } 

    public class IndexController : ControllerBase { 
    [Authenticate] 
    public ActionResult Index() { 
     return View(); 
    } 
    } 

我第一次通過從Visual Studio啓動站點來測試代碼,重定向到/ login路由。

現在,如果我從Visual Studio再次啓動站點,則會引發下面顯示的空引用異常,並且每次重啓都會發生這種情況,直到我刪除瀏覽器中的所有Cookie爲止。

看起來像一個錯誤?

NullReferenceException: Object reference not set to an instance of an object.] 
    ServiceStack.Mvc.ServiceStackController`1.get_UserSession() in C:\src\ServiceStack\src\ServiceStack.FluentValidation.Mvc3\Mvc\ServiceStackController.cs:28 
    ServiceStack.Mvc.ServiceStackController`1.get_AuthSession() in C:\src\ServiceStack\src\ServiceStack.FluentValidation.Mvc3\Mvc\ServiceStackController.cs:39 
    ServiceStack.Mvc.ExecuteServiceStackFiltersAttribute.OnActionExecuting(ActionExecutingContext filterContext) in C:\src\ServiceStack\src\ServiceStack.FluentValidation.Mvc3\Mvc\ExecuteServiceStackFiltersAttribute.cs:21 
    System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation) +47 
    System.Web.Mvc.<>c__DisplayClass17.<InvokeActionMethodWithFilters>b__14() +19 
    System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation) +263 
    System.Web.Mvc.<>c__DisplayClass17.<InvokeActionMethodWithFilters>b__14() +19 
    System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodWithFilters(ControllerContext controllerContext, IList`1 filters, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +191 
    System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +343 
    System.Web.Mvc.Controller.ExecuteCore() +116 
    System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) +97 
    System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContext requestContext) +10 
    System.Web.Mvc.<>c__DisplayClassb.<BeginProcessRequest>b__5() +37 
    System.Web.Mvc.Async.<>c__DisplayClass1.<MakeVoidDelegate>b__0() +21 
    System.Web.Mvc.Async.<>c__DisplayClass8`1.<BeginSynchronous>b__7(IAsyncResult _) +12 
    System.Web.Mvc.Async.WrappedAsyncResult`1.End() +62 
    System.Web.Mvc.<>c__DisplayClasse.<EndProcessRequest>b__d() +50 
    System.Web.Mvc.SecurityUtil.<GetCallInAppTrustThunk>b__0(Action f) +7 
    System.Web.Mvc.SecurityUtil.ProcessInApplicationTrust(Action action) +22 
    System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +60 
    System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +9 
    System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +8970061 
    System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +184 

回答

0

好的沒關係。我遇到的錯誤可能是因爲我還沒有實現登錄路線。