ServiceStack AuthenticateAttribute ส่งผลให้เกิดข้อยกเว้นการอ้างอิง null เป็นครั้งที่สอง เว้นแต่คุกกี้จะถูกลบ

ฉันกำลังพยายามให้ ServiceStacks Authentication ทำงานบนไซต์ MVC คอนโทรลเลอร์ของฉันเป็นเช่นนี้:

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

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

ครั้งแรกที่ฉันทดสอบโค้ดโดยเริ่มต้นไซต์จาก Visual Studio จะมีการเปลี่ยนเส้นทางไปยังเส้นทาง /login

ตอนนี้ถ้าฉันเริ่มไซต์อีกครั้งจาก Visual Studio ข้อยกเว้นการอ้างอิงที่เป็นโมฆะที่แสดงด้านล่างจะหายไป และสิ่งนี้จะเกิดขึ้นทุกครั้งที่รีสตาร์ทจนกว่าฉันจะลบคุกกี้ทั้งหมดในเบราว์เซอร์ของฉัน

ดูเหมือนมีข้อผิดพลาดใช่ไหม?

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

person ssn    schedule 09.08.2012    source แหล่งที่มา


คำตอบ (1)


โอเคไม่เป็นไร. ข้อผิดพลาดที่ฉันพบอาจเป็นเพราะฉันยังไม่ได้ใช้เส้นทางการเข้าสู่ระบบ

person ssn    schedule 14.08.2012