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?
What should you do?
You deploy a custom Web Part named WebPart1 to a SharePoint site.
WebPart1 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 = null;
04 try
05 {
06 SPSite site = new SPSite(“http://www.contoso.com/default.aspx”);
07 SPWeb web = site.OpenWeb();
08
09 …
10 }
11 catch
12 {
13
14 }
15 finally
16 {
17
18 }
19 }
After you deploy WebPart1, users report that the pages on the site load slowly.
You retract WebPart1 from the site.
Users report that the pages on the site load without delay. You need to modify the code in WebPart1 to prevent the pages from loading slowly.
What should you do?
Which code segment should you add?
You have a Web application that contains the following code segment.
private void CreatingSPSite()
{
SPSite siteCollection = null;
try
{
siteCollection = new SPSite(“http://contoso.com”);
}
finally
{
}
}
You need to prevent the code segment from causing a memory leak.
Which code segment should you add?
Which code segment should you include in the helper method?
You have a helper method named CreateSiteColumn that contains the following code segment.
private static void CreateSiteColumn(SPWeb web, string columnName)
{
}
You need to add a new site column of type Choice to a SharePoint site by using the helper method.
Which code segment should you include in the helper method?