Web API methods not getting profile data

rzierothrzieroth Posts: 4
edited June 30, 2014 6:09PM in ANTS Performance Profiler 8
I have a Web API method which I am trying to profile. When I make the call to the web api I can see the profiler track the construction of the controller but the api method is not getting any profile data captured.

[ResponseType(typeof(ResponseMessage))]
public IHttpActionResult Post(RequestMessage inRequest)
{
var engine = EngineFactory.GetMyEngine(inRequest);
var aResult = engine.GetRecommendations(inRequest, RequestContext);
return Ok<ResponseMessage>(recommendationResult);
}

Any ideas on what is going on?

Comments

  • Brian DonahueBrian Donahue Posts: 6,590 Bronze 1
    Hi,

    Is it because the application you are profiling is the consumer of the webservice, and the web methods are running in a WCF service hosted in a webserver? In that case, you can profile the webservice to see these results.
  • I have narrowd down that it has to do with passing complex objects as parameters to web api methods.

    I have a Web API Controller with 4 methods. The first two
    Post(int id) and Get(int id) get profile data.
    The next two do not get profile data.
    Get(MyObject inputObject)
    Post(MyObject inputObject)

    I start the Ants profile session using IIS original port and I have the Tools>Advanced Options>"Simplify very complex stack traces" and Avoid Profiling extremely trivial Method" unchecked.

    IE gets launched to my homepage controllers.
    Then I execute calls in fiddler and get 200 responses for all 4 calls with approrpiate response bodies.
    I then go back to ANTS and stop the profile. In the methods view I need to uncheck the "Hide insignificant methods" checkbox as these apis are very simple.
    I can see the data for api for the simple Post(int id) and Get(int id) but not the other two.

    Here is the controller class.
    public class TestComplexInputController : ApiController
        &#123;
            public int Post&#40;int id&#41;
            &#123;
                return id;
            &#125;
            public int Get&#40;int id&#41;
            &#123;
                return id;
            &#125;
    
            public int Get&#40;MyObject inputObject&#41;
            &#123;
                return inputObject.number;
            &#125;
            public int Post&#40;MyObject inputObject&#41;
            &#123;
                return inputObject.number;
            &#125;
    
            public class MyObject
            &#123;
                public int number;
            &#125;
        &#125;
    

    Here are the calls I make in fiddler
    ==========================================================
    
    GET http://mytest.mysite.com/PerformanceTraining/api/TestComplexInput/234 HTTP/1.1
    User-Agent: Fiddler
    Host: mytest.mysite.com
    Pragma: no-cache
    Content-Type: application/json
    
    ==========================================================
    
    POST http://mytest.mysite.com/PerformanceTraining/api/TestComplexInput/1234 HTTP/1.1
    User-Agent: Fiddler
    Host: mytest.mysite.com
    Pragma: no-cache
    Content-Type: application/json
    Content-Length: 0
    
    ==========================================================
    
    POST http://mytest.mysite.com/PerformanceTraining/api/TestComplexInput HTTP/1.1
    User-Agent: Fiddler
    Host: mytest.mysite.com
    Pragma: no-cache
    Content-Type: application/json
    Content-Length: 15
    
    &#123;"number":1234&#125;
    
    ==========================================================
    
    GET http://mytest.mysite.com/PerformanceTraining/api/TestComplexInput HTTP/1.1
    User-Agent: Fiddler
    Host: mytest.mysite.com
    Pragma: no-cache
    Content-Type: application/json
    Content-Length: 15
    
    &#123;"number":1234&#125;
    
  • Brian, I am definately profiling the correct process as I see other methods in the same file get profiling data.
Sign In or Register to comment.