Ievgen
Ievgen

Reputation: 4443

Unique id of page request in sharepoint

I need to cache one very important thing during one page cycle. I want to use a unique request id like correlation id.

How can I get such an id in SharePoint?

Upvotes: 1

Views: 817

Answers (1)

Rikard Uppström
Rikard Uppström

Reputation: 1413

See this excellent blogpost for details about using the SharePoint correlation ID: http://www.wictorwilen.se/Post/Working-with-SharePoint-2010-Correlation-ID-in-PowerShell-and-code.aspx

Update: This is how he does it:

[DllImport("advapi32.dll")]
public static extern uint EventActivityIdControl(uint controlCode, ref Guid activityId);
public const uint EVENT_ACTIVITY_CTRL_GET_ID = 1;

And then use it in code like below, perhaps in a catch statement:

Guid g = Guid.Empty;
EventActivityIdControl(EVENT_ACTIVITY_CTRL_GET_ID, ref g);
this.Controls.Add(new Label { 
    Text = string.Format("An error occurred with correlation id {0}", g)
});

Upvotes: 2

Related Questions