PrepAway - Latest Free Exam Questions & Answers

Which code segment should you insert at line 13?

You create a Microsoft ASP.NET application by using the Microsoft .NET Framework version 3.5.
You create a Web page that has a GridView control named GridView1. The GridView1 control displays the data from a database named Region and a table named Location.
You write the following code segment to populate the GridView1 control. (Line numbers are included for reference only.)

01Protected Sub Page_Load(sender As Object, e As EventArgs)
02 Dim connstr As String
03
04 SqlDependency.Start(connstr)
05 Using connection As New SqlConnection(connstr)
06 Dim sqlcmd As New SqlCommand()
07 Dim expires As DateTime = DateTime.Now.AddMinutes(30)
08 Dim dependency As New SqlCacheDependency("Region", "Location")
09 Response.Cache.SetExpires(expires)
10 Response.Cache.SetValidUntilExpires(True)
11 Response.AddCacheDependency(dependency)
12 sqlcmd.Connection = connection
13
14 GridView1.DataSource = sqlcmd.ExecuteReader()
15 GridView1.DataBind()
16 End Using
17 End Sub

You need to ensure that the proxy servers can cache the content of the GridView1 control.
Which code segment should you insert at line 13?

PrepAway - Latest Free Exam Questions & Answers

A.
Response.Cache.SetCacheability(HttpCacheability.[Private])

B.
Response.Cache.SetCacheability(HttpCacheability.[Public])

C.
Response.Cache.SetCacheability(HttpCacheability.Server)

D.
Response.Cache.SetCacheability(HttpCacheability.ServerAndPrivate)

Explanation:
HttpCacheability

NoCache Sets the Cache-Control: no-cache header. Without a field name, the directive applies to the entire request and a shared (proxy server) cache must force a successful revalidation with the origin Web server before satisfying the request. With a field name, the directive applies only to the named field; the rest of the response may be supplied from a shared cache.
Private Default value. Sets Cache-Control: private to specify that the response is cacheable only on the client and not by shared (proxy server) caches.
Server Specifies that the response is cached only at the origin server. Similar to the NoCache option. Clients receive a Cache-Control: no-cache directive but the document is cached on the origin server. Equivalent to ServerAndNoCache.
ServerAndNoCache Applies the settings of both Server and NoCache to indicate that the content is cached at the server but all others are explicitly denied the ability to cache the response.
Public Sets Cache-Control: public to specify that the response is cacheable by clients and shared (proxy) caches.
ServerAndPrivate Indicates that the response is cached at the server and at the client but nowhere else. Proxy servers are not allowed to cache the response.


Leave a Reply