Web Developer Framework 4.0 Sample Questions – 16

Question: You are developing an ASP.NET Web application. The application will contain a page that is customized for various browsers. The application will use output caching to optimize performance. You need to ensure that the page is cached by browser type and major version only. Which attribute should you add to the OutputCache directive?

  1. VaryByCustom=”browser”
  2. VaryByCustom=”User-Agent”
  3. VaryByHeader=”browser”
  4. VaryByHeader=”User-Agent”

Correct Answer: 1


Question: You are developing an ASP.NET Web application. Application data is stored in a Microsoft SQL Server 2008 database. You configure a connection string named cnnContoso. The application must cache the data that is returned from the database by using this connection string. You need to ensure that the application checks the database every 10 seconds. What should you do?

  1. Add the following configuration to the <system.web> section of the web.config file.
    <caching><outputCacheSettings><outputCacheProfiles><add name="cnnContoso" duration="10" /></outputCacheProfiles></outputCacheSettings> </caching>
  2. Add the following configuration to the <system.web> section of the web.config file.
    <caching><sqlCacheDependency enabled="true" pollTime="10000"><databases><add name="ContosoDatabase" connectionStringName="cnnContoso" /></databases></sqlCacheDependency> </caching>
  3. Add the following @ Page directive to pages that query the database.
    <%@ OutputCache Duration="10" VaryByParam="cnnContoso" %>
  4. Add the following @ Page directive to pages that query the database.
    <%@ OutputCache Duration="10000" VaryByParam="cnnContoso" %>

Correct Answer: 2


Question: You are developing an ASP.NET Web page that includes a text box control. The page includes a server-side method named ValidateValue. You need to configure the page so that the text box value is validated by using the ValidateValue method. Which two actions should you perform? (Each correct answer presents part of the solution. Choose two.)

  1. Use the CompareValidator control.
  2. Use the CustomValidator control.
  3. Set ValidationGroup on the control to ValidateValue.
  4. Set OnServerValidate on the control to ValidateValue.

Correct Answer: 2 & 4


Question: You are developing an ASP.NET Web page. You add the following markup to the page.
<asp:FileUpload id="FileUpload1" runat="server" />
<asp:Button id="btnUpload" Text="Upload selected file" OnClick="btnUpload_Click" runat="server" />
<asp:Label id="lblFeedback" runat="server" />

You add the following code segment to the code-behind. (Line numbers are included for reference only.)
01protected void btnUpload_Click(object sender,EventArgs e)
02{
03if (& )
04{
05string saveName = Path.Combine(@”c:uploadedfiles”,FileUpload1.FileName);
06
07lblFeedback.Text = “File successfully uploaded.”;
08}
09else 10{
11lblFeedback.Text = “File upload failed.”;
12}
13}
You need to save the uploaded file and display a message to the user that indicates that the upload either succeeded or failed. Which two actions should you perform? (Each correct answer presents part of the solution. Choose two.)

  1. Replace line 03 with the following code segment.
    if (FileUpload1.HasFile)
  2. Replace line 03 with the following code segment.
    if (FileUpload1.FileContent.Length > 0)
  3. Insert the following code segment at line 06.
    FileUpload1.SaveAs(saveName);
  4. Insert the following code segment at line 06.
    FileUpload1.FileContent.CopyTo(new FileStream(saveName, FileMode.Open));

Correct Answer: 1 & 3


Question: You are developing an ASP.NET Web page named WebPage.aspx. The page includes a user control named UserInfoControl.ascx. You need to expose a control property named FirstName and read its value from the page. Which two actions should you perform? (Each correct answer presents part of the solution. Choose two.)

  1. Add the following code segment to UserInfoControl.ascx.cs.
    protectedstringFirstName{get;set;}
  2. Add the following code segment to UserInfoControl.ascx.cs.
    publicstringFirstName{get;set;}
  3. Add the following code segment to WebPage.aspx.cs.
    var firstName = UserInfoControl1.Attributes["FirstName"];
  4. Add the following code segment to WebPage.aspx.cs.
    var firstName = UserInfoControl1.FirstName;

Correct Answer: 2 & 4

Tagged . Bookmark the permalink.

Leave a Reply