GetUsageData () in the web part returns null

I am trying to display some usage data for SharePoint in a web part.

Here is my code:

SPSite spSiteCollection = new SPSite(myURL) spSiteCollection.CatchAccessDeniedException = false; SPWeb spWeb = spSiteCollection.OpenWeb(); DataTable dtResults = new DataTable(); dtResults = spWeb.GetUsageData(SPUsageReportType.url, SPUsagePeriodType.lastMonth); 

The DataTable, which should contain the results, is always zero. I also tried running this from an aspx page, but nothing.

+4
source share
1 answer

I think before you can get usage data, you need to set up your farm and activate the usage report .

+3
source

All Articles