sharepoint中页面请求的唯一ID

时间:2012-02-29 11:38:30

标签: asp.net sharepoint sharepoint-2010

我需要在一个页面循环中缓存一个非常重要的事情。 我想使用唯一的请求ID,如相关ID。

如何在SharePoint中获得此类ID?

1 个答案:

答案 0 :(得分:2)

有关使用SharePoint相关ID的详细信息,请参阅此优秀博文:http://www.wictorwilen.se/Post/Working-with-SharePoint-2010-Correlation-ID-in-PowerShell-and-code.aspx

更新: 他就是这样做的:

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

然后在下面的代码中使用它,也许在catch语句中使用它:

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)
});