Which code segment should you use?

You are implementing an ASP.NET Web site. The site uses a component that must be dynamically
configured before it can be used within site pages. You create a static method named
SiteHelper.Configure that configures the component. You need to add a code segment to the
Global.asax file that invokes the SiteHelper.Configure method the first time, and only the first time,
that any page in the site is requested. Which code segment should you use?

You are implementing an ASP.NET Web site. The site uses a component that must be dynamically
configured before it can be used within site pages. You create a static method named
SiteHelper.Configure that configures the component. You need to add a code segment to the
Global.asax file that invokes the SiteHelper.Configure method the first time, and only the first time,
that any page in the site is requested. Which code segment should you use?

A.
Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs) SiteHelper.Configure()
End Sub

B.
Sub Application_Init(ByVal sender As Object, ByVal e As EventArgs) SiteHelper.Configure()
End Sub

C.
Sub Application_BeginRequest(ByVal sender As Object,
ByVal e As EventArgs)
SiteHelper.Configure()
End Sub

D.
Dim lockObject As Object = New Object()
Sub Application_BeginRequest(ByVal sender As Object,
ByVal e As EventArgs)
SyncLock (lockObject())
SiteHelper.Configure()
End SyncLock
End Sub



Leave a Reply 0

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