Topic 2, Web Application

 

Background

You are developing an online shopping web application.

 

Business Requirements

A user is not required to provide an email address. If a user enters an email address, it must be verified to be a valid email address.

Information about the first product on the product page must fade out over time to encourage the user to continue browsing the catalog.

Administrators must be able to edit information about existing customers.

Administrators also must be able to specify a default product on the product page.

 

Technical Requirements

General

The web store application is in a load-balanced web farm. The load balancer is not configured to use server affinity.

The web store application is an ASP.NET MVC application written in Visual Studio 2012.

 

Products

The value of the productId property must always be greater than 0.

The Products page for mobile devices must display to mobile users. The Products page for desktop devices must display to desktop users.

 

Storage

The data must be stored in a serialized XML data format.

Serialized objects must be schema-independent.

 

Exception handling

Exceptions originating from IIS must display a page with support contact information.

Some page links expire, and users who access these links encounter 404 errors.

Exceptions must be logged by using the WriteLog method of the Utility class.

 

Browser and device support

The application must support image format conversions from .bmp to .jpeg for mobile devices.

The application must support image format conversions from .bmp to .png for desktop devices.

 

Application Structure

clip_image002

clip_image004

clip_image006

 

 

 

 

 

 

QUESTION 1

You need to modify the application to meet the productId requirement.

 

Which code segment should you use?

 

clip_image008

 

A.

Option A

B.

Option B

C.

Option C

D.

Option D

 

Correct Answer: C

Explanation:

Scenario: The value of the productId property must always be greater than 0.

 

Note: The Contract.Requires(Of TException) method specifies a precondition contract for the enclosing method or property, and throws an exception if the condition for the contract fails.

Syntax:

‘Declaration

Public Shared Sub Requires(Of TException As Exception) ( _ condition As Boolean _) Type Parameters

TException

The exception to throw if the condition is false.

Parameters

condition

Type: System.Boolean

The conditional expression to test.

 

Reference: Contract.Requires(Of TException) Method (Boolean)

 

 

 

 

 

 

QUESTION 2

You are designing a Windows Communication Foundation (WCF) service that uses the Product class.

 

You need to update the class to meet the storage requirement.

 

What should you do? (Each correct answer presents part of the solution. Choose all that apply.)

 

A.

Mark the Product class with the DataContract attribute.

B.

Mark the public members of the Product class with the DataContractFormat attribute.

C.

Mark the Product class with the CollectionDataContract attribute.

D.

Mark the public members of the Product class with the DataMember attribute.

 

Correct Answer: AD

Explanation:

So as of .NET 3.5 SP1, you don’t have to add data contract or data member attributes anymore – if you don’t then the data contract serializer will serialize all public properties on your class, just like the XML serializer would. HOWEVER: by not adding those attributes, you lose a lot of useful capabilities:

without [DataContract], you cannot define an XML namespace for your data to live in

without [DataMember], you cannot serialize non-public properties or fields

without [DataMember], you cannot define an order of serialization (Order=) and the DCS will serialize all properties alphabetically

without [DataMember], you cannot define a different name for your property (Name=)

without [DataMember], you cannot define things like IsRequired= or other useful attributes

without [DataMember], you cannot leave out certain public properties – all public properties will be serialized by the DCS

 

 

QUESTION 3

HOTSPOT

You need to implement the mobile device support requirements.

 

How should you build the ProcessRequest method?

 

To answer, select the appropriate options in the answer area.

 

clip_image010

 

Correct Answer:

clip_image012

 

 

 

 

 

QUESTION 4

When users attempt to retrieve a product from the product page, a run-time exception occurs if the product does not exist.

 

You need to route the exception to the CustomException.aspx page.

 

Which method should you add to MvcApplication?

 

clip_image014

 

A.

Option A

B.

Option B

C.

Option C

D.

Option D

 

Correct Answer: B

 

 

 

 

 

 

QUESTION 5

An advertising campaign was recently launched. Some of the ads contain a link to products that no longer exist or have IDs that have changed.

 

You need to ensure that all product links display a product.

 

Which code segment should you use to configure the route?

 

clip_image015

 

A.

Option A

B.

Option B

C.

Option C

D.

Option D

 

Correct Answer: A

 

 

QUESTION 6

You need to modify the application to meet the productId requirement.

 

What should you do?

 

A.

Modify the RegisterGlobalFilters method of the Global.asax.cs file as follows. Contract.Assume<ArgumentException>(productId != 0);

B.

Modify the GetDealPrice method of ProductController as follows. Contract.Requires<ArgumentException>(productId > 0);

C.

Modify the RegisterGlobalFilters method of the Global.asax.cs file as follows. Contract.Requires<ArgumentException>(productId > 0);

D.

Modify the GetDealPrice method of ProductController as follows. Contract.Assume<ArgumentException>(productId > 0);

 

Correct Answer: B

Explanation:

The Contract.Requires(Of TException) method specifies a precondition contract for the enclosing method or property, and throws an exception if the condition for the contract fails.

Syntax:

‘Declaration

Public Shared Sub Requires(Of TException As Exception) ( _ condition As Boolean _) Type Parameters

TException

The exception to throw if the condition is false.

Parameters

condition

Type: System.Boolean

The conditional expression to test.

 

Reference: Contract.Requires(Of TException) Method (Boolean)

 

 

QUESTION 7

You need to implement client-side animations according to the business requirements.

 

Which line of code should you use? (Each correct answer presents a complete solution. Choose all that apply.)

 

A.

$ (“h1: first”) .animate ({ opacity: 0 });

B.

$(“h1:first”).fadeIn(1000)
;

C.

$(“h1:first”).animate({ opacity: 1 });

D.

$(“h1:first”).fadeOut(1000);

 

Correct Answer: AD

 

 

QUESTION 8

You need to configure session storage in the web.config file to meet the technical requirements for scalability.

 

Which SessionState mode should you use? (Each correct answer presents a complete solution. Choose all that apply.)

 

A.

StateServer

B.

InProc

C.

AutoDetect

D.

SqlServer

 

Correct Answer: AD

 

 

 

 

QUESTION 9

You need to implement the requirements for handling IIS errors.

 

What should you do?

 

clip_image017

 

A.

Option A

B.

Option B

C.

Option C

D.

Option D

 

Correct Answer: A

 

 

QUESTION 10

You updated the web.config file with the HTTP run-time value required to display an alternative version of the site.

 

You need to ensure that the correct page displays to the users.

 

Which code segment should you use to update the controller?

 

A.

If (Request.IsTabletDevice)

B.

If (Request.Browser.IsBrowser(“Mobile”))

C.

If (Request.UserAgent[“Tablet”])

D.

If (Request.Browser.IsMobileDevice)

 

Correct Answer: D

 

 

QUESTION 11

The GetDealPrice method must be called by using Ajax.

 

You need to get the price of a product by using the GetDealPrice method of the ProductController.

 

Which code segment should you use? (Each correct answer presents a comp
lete solution. Choose all that apply.)

 

A.

Option A

B.

Option B

C.

Option C

D.

Option D

 

Correct Answer: CD

 

 

QUESTION 12

You need to add a method to the ProductController class to meet the exception handling requirements for logging.

 

Which code segment should you use?

 

clip_image019

 

A.

Option A

B.

Option B

C.

Option C

D.

Option D

 

Correct Answer: A

 

 

 

 

 

 

QUESTION 13

You need to update the routes to ensure that a product is always displayed on the product page.

 

Which code segment should you use?

 

clip_image021

 

A.

Option A

B.

Option B

C.

Option C

D.

Option D

 

Correct Answer: B

 

 

QUESTION 14

You need to implement the business requirements for managing customer data.

 

What should you do? (Each correct answer presents part of the solution. Choose all that apply.)

 

A.

Add a class named Customer-Controller to the Controllers folder. Then add a method named Edit to the class.

B.

Create a new controller named Administration in the Controllers folder. Add an action named EditCustomer to the controller.

C.

Add a folder named Customer to the Views folder. Then create a view inside this folder named Edit.aspx.

D.

Create a new folder named EditCustomer to the Views folder. In the new folder, create a new file named Administration.aspx.

 

Correct Answer: AB

 

 

QUESTION 15

You need to implement client-side animations according to the business requirements.

 

Which line of code should you use? (Each correct answer presents a complete solution. Choose all that apply.)

 

A.

$(“body h1:nth-child(1)”).fadeIn(1000);

B.

$(“body h1:nth-child(1)”)-fadeOut(1000);

C.

$(“body h2:nth-child(1)”).animate({ opacity: 0 });

D.

$(“body h1:nth-child(1)”).animate({ opacity: 1 });

 

Correct Answer: BC

 

 

QUESTION 16

You need to ensure that new customers enter a valid email address.

 

Which code should you use? (Each correct answer presents part of the solution. Choose all that apply.)

 

clip_image023

 

A.

Option A

B.

Option B

C.

Option C

D.

Option D

 

Correct Answer: AD

 

Free VCE & PDF File for Microsoft 70-494 Real Exam

Instant Access to Free VCE Files: MCSE|MCSA|MCITP…
Instant Access to Free PDF Files: MCSE|MCSA|MCITP…