nerdexam
Microsoft

70-573 · Question #202

You are creating a new Web Part. You need to create a reference to the current subsite without having to dispose of any returned objects. Which code segment should you use? Dim site As…

The correct answer is D. Dim site As SPWeb = SPContext.Current.Web. See the full explanation below for the reasoning.

Question

You are creating a new Web Part. You need to create a reference to the current subsite without having to dispose of any returned objects. Which code segment should you use? Dim site As SPWebCollection = siteCollection.AllWebs Dim site As SPWeb = siteCollection.RootWeb

Options

  • CDim site As SPSite = SPContext.Current.Site
  • DDim site As SPWeb = SPContext.Current.Web

How the community answered

(29 responses)
  • C
    21% (6)
  • D
    79% (23)

Community Discussion

No community discussion yet for this question.

Full 70-573 Practice