Getting more “granularity” from the MVC Mini Profiler

后端 未结 3 527
梦毁少年i
梦毁少年i 2021-02-04 10:58

Should this turn out to be useful for anyone, I\'ll gladly turn it into a community wiki thing.

I have some slow pages in an MVC3 app, and since little of the execution

3条回答
  •  夕颜
    夕颜 (楼主)
    2021-02-04 11:48

    This looks like a cool idea. I believe that it's NOT a request safe way of doing things.

    You could link it to HttpContext.Items like this

    HttpContext.Items.Add("actionstep", actionStep);
    HttpContext.Items.Add("resultstep", resultStep);
    

    And then retrieve it in similar fashion

    actionStep = HttpContext.Items["actionstep"];
    resultStep = HttpContext.Items["resultstep"];
    

    Obviously putting in your own checks for nulls and so forth.

    The HttpContext is different for each user/request.

    The thing to remember about HttpContext.Current.Session.SessionID which I sometimes forget it that it is the SessionId of the current HTTP request (i.e. it changes each time you hit F5 or otherwise make a new request). The other important thing to remember is that, whilst at any on time, all HttpContext.Current.Session.SessionID values are necessarily unique (i.e. one for each user, or request), they can be reused, so dno't think of them as GUIDs which are only used once each.

提交回复
热议问题