Home » [Free] Get all latest Microsoft 70-515 Actual Tests 11-20

[Free] Get all latest Microsoft 70-515 Actual Tests 11-20

Ensurepass

QUESTION 11

You create a new ASP.NET MVC 2 Web application. The following default routes are created in the Global.asax.vb file. (Line numbers are included for reference only.)

 

01 Shared Sub RegisterRoutes(ByVal routes As RouteCollection) 03 routes.IgnoreRoute(“{resource}.axd/{*pathInfo}”)

 

02

 

03

 

04

 

05 routes.MapRoute(

 

“Default”,

 

“{controller}/{action}/{id}”,

 

New With {.controller = “Home”, .action = “Index”, .id = “”}

 

)

 

06 End Sub

 

You implement a controller named HomeController that includes methods with the following signatures.

 

Function Index() As ActionResult

 

Function Details(ByVal id As Integer) As ActionResult

 

Function DetailsByUsername(

 

ByVal username As String) As ActionResult

 

You need to add a route to meet the following requirements:

 

clip_image002The details for a user must be displayed when a user name is entered as the path by invoking the DetailsByUsername action.

clip_image002[1]User names can contain alphanumeric characters and underscores, and can be between 3 and 20 characters long.

 

What should you do?

 

A.

Replace line 05 with the following code segment. routes.MapRoute(“Default”, “{controller}/{action}/{id}”, New With {.controller = “Home”, .action = “DetailsByUsername”,.id = “”})

B.

Replace line 05 with the following code segment. routes.MapRoute( “Default”, “{controller}/{action}/{username}”, New With {.controller = “Home”, .action = “DetailsByUsername”, .username = “”},New With {.username = “w{3,20}”})

C.

At line 04, add the following code segment.

routes.MapRoute(“Details by Username”,”{username}”, New With {.controller = “Home”, .action = “DetailsByUsername”}, New With {.username = “w{3,20}”} )

D.

At line 04, add the following code segment.

routes.MapRoute( “Details by Username”, “{id}”, New With {.controller = “Home”, .action =

“DetailsByUsername”},New With {.id = “w{3,20}”} )

 

Correct Answer: C

 

 

QUESTION 12

You are implementing an ASP.NET MVC 2 Web application that contains several folders.

 

The Views/Shared/DisplayTemplates folder contains a templated helper named Score.ascx that performs custom formatting of integer values.

 

The Models folder contains a class named Player with the following definition.

 

Public Class Player

 

Public Property Name As String

 

Public Property LastScore As Integer

 

Public Property HighScore As Integer

 

End Class

 

You need to ensure that the custom formatting is applied to LastScore values when the HtmlHelper.DisplayForModel method is called for any view in the application that has a model of type Player.

 

What should you do?

 

A.

Rename Score.ascx to LastScore.ascx.

B.

Move Score.ascx from the Views/Shared/DisplayTemplates folder to the Views/Player/DisplayTemplates folder.

C.

Add the following attribute to the LastScore property.

<UIHint(“Score”)>

D.

Add the following attribute to the LastScore property.

<Display(Name:=”LastScore”, ShortName:=”Score”)>

 

Correct Answer: C

 

 

 

 

 

QUESTION 13

You are implementing an ASP.NET MVC 2 application. In the Areas folder, you add a subfolder named Product to create a single project area.

 

You add files named ProductController.vb and Index.aspx to the appropriate subfolders.

 

You then add a file named Route.vb to the Product folder that contains the following code.

(Line numbers are included for reference only.)

 

01 Public Class Route

 

Inherits AreaRegistration

 

02

 

03 Public Overrides ReadOnly Property AreaName As String

 

04 Get

 

05 Return “product”

 

06 End Get

 

07 End Property

 

08

 

09 Public Overrides Sub RegisterArea(

 

ByVal context As AreaRegistrationContext)

 

10

 

11 context.MapRoute(“product_default”,

 

“product/{controller}/{action}/{id}”,

 

New With {.controller = “Product”, .action = “Index”,

 

.id = “”})

 

12

 

13 End Sub

 

End Class

 

When you load the URL http://<applicationname>/product, you discover that the correct page is not returned. You need to ensure that the correct page is returned.

 

What should you do?

 

A.

Replace line 11 with the following code segment.

context.MapRoute(“product_default”,

“{area}/{controller}/{action}/{id}”,

New With {.area = “product”, .controller = “Product”, .action = “Index”, .id = “”})

B.

Replace line 11 with the following code segment.

context.MapRoute(“product_default”,

“{area}”,

New With {.controller = “Product”, .action = “Index”, .id = “”})

C.

Add the following code segment at line 12.

AreaRegistration.RegisterAllAreas()

D.

Add the following code segment to the RegisterRoutes method in the Global.asax.vb file.

AreaRegistration.RegisterAllAreas()

 

Correct Answer: D

 

 

QUESTION 14

You are implementing an ASP.NET MVC 2 Web application that contains the following class.

 

Public Class DepartmentController

 

Inherits Controller

 

Shared departments As List(Of Department) =

 

New List(Of Department)

 

Function Index() As ActionResult

 

Return View(departments)

 

End Function

 

Function Details(ByVal id As Integer) As ActionResult

 

Return View(departments.Find(Function(x) x.ID = id))

 

End Function

 

Function ListEmployees(ByVal d As Department) As ActionResult

 

Dim employees As List(Of Employee) = GetEmployees(d)

 

Return View (employees)

 

End Function

 

End Class

 

You create a strongly typed view that displays details for a Department instance. You want the view to also include a listing of department employees.

 

You need to write a code segment that will call the ListEmployees action method and output the results in place.

 

Which code segment should you use?

 

A.

<%= Html.Action(“ListEmployees”, Model) %>

B.

<%= Html.ActionLink(“ListEmployees”, “Department”, “DepartmentController”) %>

C.

<% Html.RenderPartial(“ListEmployees”, Model) %>

D.

<%= Html.DisplayForModel(“ListEmployees”) %>

 

Correct Answer: A

Explanation:

Html.Action(string, object) invokes a child action method and returns the result as an HTML string.

ChildActionExtensions.Action Method

(http://msdn.microsoft.com/en-

s/library/system.web.mvc.html.childactionextensions.action.aspx) Html.DisplayForModel() Method returns HTML markup for each property in the model. Html.DisplayForModel(string, object) Method returns HTML markup for each property in the model, using the specified template and additional view data.

 

RenderPartialExtensions.RenderPartial Method

(http://msdn.microsoft.com/en-

us/library/system.web.mvc.html.renderpartialextensions.renderpartial.aspx) The ActionLink method renders an element that links to an action method.

LinkExtensions.ActionLink Method

(http://msdn.microsoft.com/en-

us/library/system.web.mvc.html.linkextensions.actionlink.aspx)

 

 

QUESTION 15

You are developing an ASP.NET MVC 2 Web application.

 

A page makes an AJAX request and expects a list of company names in the following format.

 

[“Adventure Works”,”Contoso”]

 

You need to write an action method that returns the response in the correct format.

 

Which type should you return from the action method?

 

A.

AjaxHelper

B.

XDocument

C.

JsonResult

D.

DataContractJsonSerializer

 

Correct Answer: C

 

 

QUESTION 16

You are developing an ASP.NET MVC 2 Web application. The application contains a controller named HomeController, which has an action named Index. The application also contains a separate area named Blog. A view within the Blog area must contain an ActionLink that will link to the Index action of the HomeController. You need to ensure that the ActionLink in the Blog area links to the Index action of the HomeController. Which ActionLink should you use?

 

A.

Html.ActionLink(“Home”, “Index”, “Home”)

B.

Html.ActionLink(“Home”, “Index”, “Home”, New With {.area = “”}, Nothing)

C.

Html.ActionLink(“Home”, “Index”, “Home”, New With {.area = “Blog”}, Nothing)

D.

Html.ActionLink(“Home”, “Index”, “Home”, New With {.area = “Home”}, Nothing)

 

Correct Answer: B

 

 

QUESTION 17

You are implementing an ASP. NET MVC 2 Web application. You add a controller named CompanyController. You need to modify the application to handle the URL path /company/info. Which two actions should you perform? (Each correct answer presents part of the solution. Choose two.)

 

A.

Add the following method to the CompanyController class.

Function Info () As ActionResult

Return View()

End Function

B.

Add the following method to the CompanyController class.

Function Company_Info() As ActionResult

Return View()

End Function

C.

Right-click the Views folder, and select View from the Add submenu to create the view for the action.

D.

Right-click inside the action method in the CompanyController class, and select Add View to create a view for the action.

 

Correct Answer: AD

Explanation:

CHAPTER 14 Creating Websites with ASP.NET MVC 2

Lesson 2: Creating Models, Views, and Controllers Creating Controllers, Creating Views (page 851-857)

 

 

QUESTION 18

You are creating an ASP.NET Web site. You create a HTTP module named CustomModule, and you register the module in the web.config file. The CustomModule class contains the following code.

 

Public Class CustomModule

 

Implements IHttpModule

 

Dim footerContent As String = “<div>Footer Content</div>”

 

Public Sub Dispose() Implements IHttpModule.Dispose

 

End Sub

 

End Class

 

You need to add code to CustomModule to append the footer content to each processed ASP.NET page.

 

Which code segment should you use?

 

A.

Public Sub New(ByVal app As HttpApplication)

AddHandler app.EndRequest, AddressOf app_EndRequest End Sub

Sub app_EndRequest(ByVal sender As Object, ByVal e As EventArgs)

Dim app As HttpApplication = TryCast(sender, HttpApplication)

app.Response.Write(footerContent)

End Sub

B.

Public Sub Init(ByVal app As HttpApplication) _ Implements IHttpModule.Init

AddHandler app.EndRequest, AddressOf app_EndRequest

End Sub

Sub app_EndRequest(ByVal sender As Object, ByVal e As EventArgs)

Dim app As HttpApplication = New HttpApplication()

app.Response.Write(footerContent)

End Sub

C.

Public Sub New()

Dim app As HttpApplication = New HttpApplication()

AddHandler app.EndRequest, AddressOf app_EndRequest

End Sub

Sub app_EndRequest(ByVal sender As Object, ByVal e As EventArgs)

Dim app As HttpApplication = TryCast(sender, HttpApplication)

app.Response.Write(footerContent)

End Sub

D.

Public Sub Init(ByVal app As HttpApplication) _ Implements IHttpModule.Init

AddHandler app.EndRequest, AddressOf app_EndRequest

End Sub

Sub app_EndRequest(ByVal sender As Object, ByVal e As EventArgs)

Dim app As HttpApplication = TryCast(sender, HttpApplication)

app.Response.Write(footerContent)

End Sub

 

Correct Answer: D

 

 

QUESTION 19

You are implementing an ASP.NET Web site. The root directory of the site contains a page named Error.aspx. You need to display the Error.aspx page if an unhandled error occurs on any page within the site. You also must ensure that the original URL in the browser is not changed. What should you do?

 

A.

Add the following configuration to the web.config file.

<system.web>

<customErrors mode=”On”>

<error statusCode=”500″ redirect=”~/Error.aspx” />

</customErrors>

</system.web>

B.

Add the following configuration to the web.config file.

<system.web>

<customErrors redirectMode=”ResponseRewrite”

mode=”On” defaultRedirect=”~/Error.aspx” />

</system.web>

C.

Add the following code segment to the Global.asax file.

Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs)

Response.Redirect(“~/Error.aspx”)

End Sub

D.

Add the following code segment to the Global.asax file.

Protected Sub Page_Load(ByVal sender As Object,

ByVal e As System.EventArgs) Handles Me.Load

Server.Transfer(“~/Error.aspx”)

End Sub

 

Correct Answer: B

 

 

QUESTION 20

You are implementing an ASP.NET Web application. Users will authenticate to the application with an ID. The application will allow new users to register for an account. The application will generate an ID for the user based on the users full name. You need to implement this registration functionality. Which two actions should you perform? (Each correct answer presents part of the solution. Choose two.)

 

A.

Configure the SqlMembershipProvider in the web.config file.

B.

Configure the SqlProfileProvider in the web.config file.

C.

Create an ASP.NET page that contains a default CreateUserWizard control to create a new user account.

D.

Create an ASP.NET page that contains a custom form that collects the user information and then uses the Membership.CreateUser method to create a new user account.

 

Correct Answer: AD

Explanation:

CHAPTER 13 Implementing User Profiles, Authentication, and Authorization Lesson 1: Working with User Profiles SqlMembershipProvider Class (http://msdn.microsoft.com/en- us/library/system.web.security. sqlmembershipprovider.aspx)

 

Instant Access to Download Testing Software & PDF File for Microsoft 70-515 Real Exam

Instant Access to Try Microsoft 70-515 Free Demo

HOT EXAM!

Name of author

Name: admin