# Missing X-MiniProfiler-Ids from headers in ajax requests

**URL:** <https://community.miniprofiler.com/t/missing-x-miniprofiler-ids-from-headers-in-ajax-requests/138>\
**Category:** uncategorized\
**Created:** [May 10, 2012, 11:57am UTC](https://community.miniprofiler.com/t/missing-x-miniprofiler-ids-from-headers-in-ajax-requests/138 "2012-05-10T11:57:10Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![WebApi](https://avatars.discourse-cdn.com/v4/letter/w/db5fbb/32.png) [@WebApi](https://community.miniprofiler.com/u/WebApi)\
**Post date:** [May 10, 2012, 11:57am UTC](https://community.miniprofiler.com/t/missing-x-miniprofiler-ids-from-headers-in-ajax-requests/138/1 "2012-05-10T11:57:10Z")

</div>

I am using a combination of mvc views and Microsoft WebApi in my application and have installed miniprofiler.

The miniprofiler works great for normal requests for MVC views but it does not refresh when I do ajax requests against webapi methods. However they show up if I refresh the page.

The ajax requests are done using jQuery 1.7.1 and calls ApiController methods in the same application.

The problem seems to be that the json response does not contain the X-MiniProfiler-Ids header.

Am I missing some configuration settings or is this an issue with miniprofiler?

If you could provide a sample for me I would really appreciate it.

Here is the code I am using:

Global.asax

```
  Shared Sub RegisterGlobalFilters(ByVal filters As GlobalFilterCollection)
        filters.Add(New ProfilingActionFilter())
    End Sub

 Sub Application_Start()
        RegisterGlobalFilters(GlobalFilters.Filters)

        Dim copy = ViewEngines.Engines.ToList()
        ViewEngines.Engines.Clear()

        For Each item In copy
            ViewEngines.Engines.Add(New ProfilingViewEngine(item))
        Next    
    End Sub

Sub Application_BeginRequest()
    StackExchange.Profiling.MiniProfiler.Start()
End Sub

Sub Application_EndRequest()
    StackExchange.Profiling.MiniProfiler.Stop()
End Sub

```

ApiController:

```
<ProfilingActionFilter()> _
        Public Function GetChallenges() As IEnumerable(Of ChallengeListItem)
            Using StackExchange.Profiling.MiniProfiler.StepStatic("GetChallenges", StackExchange.Profiling.ProfileLevel.Info)
                Dim vAuthToken As Guid
                Guid.TryParse(HttpContext.Current.Request.Headers.GetValues(AUTHORIZATIONTOKENKEY).FirstOrDefault(), vAuthToken)

                Dim vChallenges As List(Of ChallengeListItem)
                vChallenges = ChallengeData.GetChallenges(vAuthToken)
                Return vChallenges
            End Using
        End Function

```

Razorview:

```
 @StackExchange.Profiling.MiniProfiler.RenderIncludes()

```

javascript request:

```
this.getChallenges = function (callback) {
            $.ajax({
                type: 'GET',
                url: 'api/Challenges/',
                beforeSend: function (xhr) {
                    xhr.setRequestHeader("Authorization-Token", userToken);
                },
                success: function (data) {
                    if (callback)
                        callback(data);
                },
                error: function (error) {
                    if (error.status == 401) { 
                        alert('Unauthorized');
                    } else {
                        alert(error.responseText);
                    }
                }
            });
        };
```

---

<div class="post-metadata">

**Author:** ![sam](https://sea2.discourse-cdn.com/flex016/user_avatar/community.miniprofiler.com/sam/32/377_2.png) [@sam](https://community.miniprofiler.com/u/sam)\
**Post date:** [May 10, 2012, 6:42pm UTC](https://community.miniprofiler.com/t/missing-x-miniprofiler-ids-from-headers-in-ajax-requests/138/2 "2012-05-10T18:42:59Z")

</div>

can you debug through it and see that `MiniProfiler.Start` and `MiniProfiler.Stop` are being called properly, could there be a filter that is stripping response headers?

---

<div class="post-metadata">

**Author:** ![Cory](https://avatars.discourse-cdn.com/v4/letter/c/898d66/32.png) [@Cory](https://community.miniprofiler.com/u/Cory)\
**Post date:** [December 1, 2012, 8:43pm UTC](https://community.miniprofiler.com/t/missing-x-miniprofiler-ids-from-headers-in-ajax-requests/138/3 "2012-12-01T20:43:05Z")

</div>

I’m having a similar issue. The profiler renders the MVC results but fails to display the API results. In my case, requests to the API are cross-origin, so I’m thinking the header is getting lost after the preflighted request. I’ve tried adding a Access-Control-Expose-Headers header with a value of “X-MiniProfiler-Ids”, but the header is still missing on my API response.
