Latest 70-515 Real Exam Download 41-50

Ensurepass

QUESTION 41

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.cs and Index.aspx to the appropriate subfolders.

You then add a file named Route.cs to the Product folder that contains the following code. (Line numbers are included for reference only.)

01 public class Routes : AreaRegistration 02 {

03 public override string AreaName 04 {

05 get { return "product"; } 06 }

07

8 public override void RegisterArea(AreaRegistrationContext context)

9 {

10 context.MapRoute("product_default", "product/{controller}/{action}/

{id}", new { controller = "Product", action = "Index", id = "" });

11 }

12 }

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 10 with the following code segment.

context.MapRoute("product_default", "{area}/{controller}/{action}/{id}", new

{area = "product", controller = "Product", action = "Index", id = ""});

B. Replace line 10 with the following code segment.

context.MapRoute("product_default", "area}",

C. Add the following code segment at line 11

AreaRegistration.RegisterAllAreas();

D. Add the following Code segment to the Register Routes in Global.asax.cs file.

AreaRegistration.RegisterAllAreas();

Answer: D


QUESTION 42

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

You create a shared user control named MenuBar.ascx that contains the application’s menu. You need to use the menu bar in all application views.

What should you do?

A. In the site’s master page, create a div element with an ID of Navigation.

Add the following code segment inside this div element.

<% Html.RenderPartial("~/Views/Shared/MenuBar.ascx"); %>

B. In the site’s master page, create a div element with an ID of Navigation.

Add the following code segment inside this div element.

<%= Url.Content("~/Views/Shared/MenuBar.ascx") %>

C. In each of the controller’s action methods, add an entry to the ViewData collection with a key of Navigation and a value of ~/Views/Shared/MenuBar.ascx.

D. In the site’s Global.asax.cs file, register a route named Navigation that points to the ~/Views/Shared/ MenuBar.ascx file.

Answer: A


QUESTION 43

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 String Name { get; set; }

public int LastScore { get; set; }

public int HighScore { get; set; }

}

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")]

Answer: C


QUESTION 44

You create an ASP.NET MVC 2 Web application that contains the following controller class.

public class ProductController : Controller

{

static List<Product> products = new List<Product>();

public ActionResult Index()

{

return View();

}

}

In the Views folder of your application, you add a view page named Index.aspx that includes the following

@ Page directive.

<%@ Page Inherits="System.Web.Mvc.ViewPage" %>

You test the application with a browser.

You receive the following error message when the Index method is invoked: "The view ‘Index’ or its master was not found."

You need to resolve the error so that the new view is displayed when the Index method is invoked. What should you do?

A. Change the name of the Index.aspx file to Product.aspx.

B. Create a folder named Product inside the Views folder. Move Index.aspx to the Product folder.

C. Replace the @ Page directive in Index.aspx with the following value.

<%@ Page Inherits="System.Web.Mvc.ViewPage<Product>" %>

D. Modify the Index method by changing its signature to the following:

public ActionResult Index(Product p)

Answer: B


QUESTION 45

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

public class DepartmentController : Controller

{

static List<Department> departments = new List<Department>();

public ActionResult Index()

{

return View(departments);

}

public ActionResult Details(int id)

{

return View(departments.Find(x => x.ID==id));

}

public ActionResult ListEmployees(Department d)

{

List<Employee> employees = GetEmployees(d);

return View(employees);

}

}

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") %>

Answer: A


QUESTION 46

You are testing an existing ASP.NET page. The page includes a text box.

You are able to execute malicious JavaScript code by typing it in the text box and submitting. You need to configure the page to prevent JavaScript code from being submitted by the text box. In the @ Page directive, which attribute should you set to true?

A. the EnableEventValidation attribute

B. the ResponseEncoding attribute

C. the ValidateRequest attribute

D. the Strict attribute

Answer: C


QUESTION 47

You are implementing an ASP.NET page in an e-commerce application.

Code in a btnAddToCart_Click event handler adds a product to the shopping cart.

The page should check the status of the shopping cart and always show a cart icon when one or more

items are in the shopping cart.

The page should hide the icon when the shopping cart has no items. You need to add an event handler to implement this requirement. Which event handler should you add?

A. btnAddToCart_Click

B. Page_Load

C. Page_PreRender

D. Page_PreInit

Answer: C


QUESTION 48

You are implementing a read-only page that includes the following controls.

<asp:Button ID="btnRefresh" runat="server" Text="Button" />

<asp:GridView ID="gvCustomers" runat="server" EnableViewState="False"

OnDataBinding="gvCustomers_DataBinding"></asp:GridView>

You disable view state to improve performance.

You need to ensure that the page is updated to display the latest data when the user clicks the refresh

button.

Which code segment should you use?

A. protected void Page_PreInit(object sender, EventArgs e)

{

if (!IsPostBack)

{

gvCustomers.DataSource = GetCustomers();

gvCustomers.DataBind();

}

}

B. protected void Page_Load(object sender, EventArgs e)

{

gvCustomers.DataSource = GetCustomers();

gvCustomers.DataBind();

}

C. protected void gvCustomers_DataBinding(object sender, EventArgs e)

{

gvCustomers.DataSource = GetCustomers();

gvCustomers.DataBind();

}

D. protected void Page_PreRender(object sender, EventArgs e)

{

if (!IsPostBack)

{

gvCustomers.DataSource = GetCustomers();

gvCustomers.DataBind();

}

}

Answer: B


QUESTION 49

You create an ASP.NET page named TestPage.aspx that contains validation controls.

You need to verify that all input values submitted by the user have been validated by testing the Page. IsValid property.

Which page event should add an event handler to?

A. Init

B. Load

C. PreInit

D. PreLoad

Answer: B


QUESTION 50

You are implementing an ASP.NET page that hosts a user control named CachedControl.

You need to ensure that the content of the user control is cached for 10 seconds and that it is regenerated when fetched after the 10 seconds elapse.

Which two actions should you perform? (Each correct answer presents part of the solution. Choose two.)

A. Modify the hosting page’s caching directive as follows.

<%@ OutputCache Duration="10" VaryByParam="None" %>

B. Add the following meta tag to the Head section of the hosting page.

<meta http-equiv="refresh" content="10">

C. Add the following caching directive to the hosted control.

<%@ OutputCache Duration="10" VaryByParam="None" %>

D. Add the following caching directive to the hosted control.

<%@ OutputCache Duration="10" VaryByControl="None" %>

Answer: AC

Download Latest 70-515 Real Free Tests , help you to pass exam 100%.