How to properly authenticate mvc-mini-profiler with AspNetSqlMembershipProvider

后端 未结 3 831
心在旅途
心在旅途 2021-02-04 07:57

I tried to check if the user is in role at Application_BeginRequest and Application_AuthenticateRequest with this code and it will not work. At BeginRequest the code is never hi

3条回答
  •  你的背包
    2021-02-04 08:48

    The cookie feanz mentions is a handy trick, a second method is profiling unconditionally and then abandoning the session for an unauthenticated user:

    protected void Application_BeginRequest()
    {
       MvcMiniProfiler.MiniProfiler.Start();  
    }
    protected void Application_AuthenticateRequest(Object sender, EventArgs e)
    {
      if(!CurrentUserIsAllowedToSeeProfiler())
      {
        MvcMiniProfiler.MiniProfiler.Stop(discardResults: true);
      }
    }
    

提交回复
热议问题