nerdexam
Microsoft

70-573 · Question #107

You create a Web Part. You need to display the number of visits to a SharePoint site collection in a label named LblVisits. You write the following code segment. (Line numbers are included for…

The correct answer is B. SPSite site = new SPSite (SPContext.Current.Site.ID ). See the full explanation below for the reasoning.

Question

You create a Web Part. You need to display the number of visits to a SharePoint site collection in a label named LblVisits. You write the following code segment. (Line numbers are included for reference only.) 01 SPSecurity.RuntfithElevatedPrivileges (delegate() 02 { 03 try 04 { 05 06 LblVisits.Text = site.Usage.Visits.ToString () ; 07 } 08 finally 09 { 10 11 } 12 } 13 ); Which code segment should you add at line 05?

Options

  • ASPSite site - SPContext.GetContext (HttpContext.Current ).Site;
  • BSPSite site = new SPSite (SPContext.Current.Site.ID );
  • CSPSite site = SPContext.Current.Site ;
  • DSPSite site - SPControl.GetContextSite (HttpContext.Current );

How the community answered

(42 responses)
  • A
    17% (7)
  • B
    74% (31)
  • C
    2% (1)
  • D
    7% (3)

Community Discussion

No community discussion yet for this question.

Full 70-573 Practice