You need to modify the Web Part to prevent the site from loading slowly

You have a Web Part that contains the following code segment. (Line numbers are included for
reference only.) 01 protected void Page_Load(object sender, EventArgs e) 02 { 03 SPSite site =
new SPSite(“http://www.contoso.com/default.aspx”); 04 { 05 SPWeb web = site.OpenWeb(); 06
07 } 08 } You deploy the Web Part to a SharePoint site. After you deploy the Web Part, users
report that the site loads slowly. You need to modify the Web Part to prevent the site from loading
slowly. What should you do?

You have a Web Part that contains the following code segment. (Line numbers are included for
reference only.) 01 protected void Page_Load(object sender, EventArgs e) 02 { 03 SPSite site =
new SPSite(“http://www.contoso.com/default.aspx”); 04 { 05 SPWeb web = site.OpenWeb(); 06
07 } 08 } You deploy the Web Part to a SharePoint site. After you deploy the Web Part, users
report that the site loads slowly. You need to modify the Web Part to prevent the site from loading
slowly. What should you do?

A.
Change line 03 to the following code segment: using (SPSite site = new
SPSite(“http://www.contoso.com/default.aspx”))

B.
Add the following line of code at line 06: site.Close();

C.
Add the following line of code at line 06: web.Dispose();

D.
Add the following line of code at line 06: web.Close();



Leave a Reply 0

Your email address will not be published. Required fields are marked *