PrepAway - Latest Free Exam Questions & Answers

Category: 70-515 (v.1)

Exam 70-515: TS: Web Applications Development with Microsoft .NET Framework 4 (update August 24th, 2013)

What are two possible ways to achieve this goal?

You are implementing an ASP.NET MVC 2 Web application.
A controller contains the following code.
public ActionResult Edit(int id)
{
return View(SelectUserToEdit(id));
}
public ActionResult Edit(Person person)
{
UpdateUser(person);
return RedirectToAction(“Index”);
}
The first Edit action displays the user whose details are to be edited, and the second Edit action is called when
the Save button on the editing form is clicked to update the user details.
An exception is thrown at run time stating that therequest for action Edit is ambiguous.
You need to correct this error and ensure that the controller functions as expected.
What are two possible ways to achieve this goal? (Each correct answer presents a complete solution. Choose
two.)

Which code segment should you use?

You create an ASP.NET MVC 2 Web application.
You implement a single project area in the application.
In the Areas folder, you add a subfolder named Test.
You add files named TestController.cs and Details.aspx to the appropriate subfolders.
You register the area’s route, setting the route name to test_default and the area name to test.
You create a view named Info.aspx that is outside the test area.
You need to add a link to Info.aspx that points to Details.aspx.
Which code segment should you use?

You need to ensure that the correct page is returned

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
08 public override void RegisterArea(AreaRegistrationContext context)
09 {
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?

You need to ensure that the custom formatting is applied to LastScore values when the HtmlHelper

You are implementing an ASP.NET MVC 2 Web application that contains several folders.
The Views/Shared/DisplayTemplates folder contains atemplated 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?

You need to resolve the error so that the new view is displayed when the Index method is invoked

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?

Which code segment should you use?

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 theListEmployees action method and output the resultsin
place.
Which code segment should you use?

Which event handler should you add?

You are implementing an ASP.NET page in an e-commerce application.
Code in a btnAddToCart_Clickevent 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?


Page 6 of 19« First...45678...Last »