Latest 70-515 Real Exam Download 31-40

Ensurepass

QUESTION 31

You are implementing an ASP.NET Web site. The site contains the following class.

public class Address

{

public int AddressType;

public string Line1;

public string Line2; public string City;

public string ZipPostalCode;

}

The Web site interacts with an external data service that requires Address instances to be given in the following XML format.

<Address AddressType="2">

<Line1>250 Race Court</Line1>

<City>Chicago</City>

<ZipCode>60603</ZipCode>

</Address>

You need to ensure that Address instances that are serialized by the XmlSerializer class meet the XML format requirements of the external data service.

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

A. Add the following attribute to the AddressType field.

[XmlAttribute]

B. Add the following attribute to the Line2 field.

[XmlElement(IsNullable=true)]

C. Add the following attribute to the ZipPostalCode field.

[XmlAttribute("ZipCode")]

D. Add the following attribute to the ZipPostalCode field.

[XmlElement("ZipCode")]

Answer: AD


QUESTION 32

You are implementing an ASP.NET Dynamic Data Web site.

The Web site includes a data context that enables automatic scaffolding for all tables in the data model. The Global.asax.cs file contains the following code segment.

public static void RegisterRoutes(RouteCollection routes)

{

routes.Add(new DynamicDataRoute("{table}/ListDetails.aspx")

{

});

Action = PageAction.List,

ViewName = "ListDetails",

Model = DefaultModel

routes.Add(new DynamicDataRoute("{table}/ListDetails.aspx")

{

});

}

Action = PageAction.Details,

ViewName = "ListDetails",

Model = DefaultModel

You need to display the items in a table named Products by using a custom layout. What should you do?

A. Add a new Web page named Products.aspx to the Dynamic DataPageTemplates folder of the Web site.

B. Add a new folder named Products to the Dynamic DataCustomPages folder of the Web site.

Add a new Web page named ListDetails.aspx to the Products folder.

C. Add a new Web user control named Products.ascx to the Dynamic DataFilters folder of the Web site.

In the code-behind file for the control, change the base class from UserControl to System.Web. DynamicData.QueryableFilterUserControl.

D. Add a new Web user control named Products_ListDetails.ascx to the Dynamic DataEntityTemplates folder of the Web site.

In the code-behind file for the control, change the base class from UserControl to System.Web. DynamicData.EntityTemplateUserControl.

Answer: B


QUESTION 33

You are implementing a new Dynamic Data Web site.

The Web site includes a Web page that has an ObjectDataSource control named ObjectDataSource1. ObjectDataSource1 interacts with a Web service that exposes methods for listing and editing instances of a class named Product.

You add a GridView control named GridView1 to the page, and you specify that GridView1 should use ObjectDataSource1 as its data source.

You then configure GridView1 to auto-generate fields and to enable editing. You need to add Dynamic Data behavior to GridView1.

You also must ensure that users can use GridView1 to update Product instances.

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

A. Add a DynamicDataManager control to the Web page.

B. Disable the auto-generated fields on GridView1. Add a DynamicField control for each field of the Product class.

C. Add the following code segment to the Application_Start method in the Global.asax.cs file.

DefaultModel.RegisterContext(typeof(System.Web.UI.WebControls. ObjectDataSource), new ContextConfiguration() {ScaffoldAllTables = true});

D. Add the following code segment to the Page_Init method of the Web page.

GridView1.EnableDynamicData(typeof(Product));

Answer: BD


QUESTION 34

You create a new ASP.NET MVC 2 Web application.

The following default routes are created in the Global.asax.cs file. (Line numbers are included for reference only.)

01 public static void RegisterRoutes(RouteCollection routes) 02 {

03 routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

5 routes.MapRoute("Default", "{controller}/{action}/{id}", new {controller

= "Home", action = "Index", id = ""});

6 }

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

public ActionResult About() public ActionResult Index()

public ActionResult Details(int id)

You need to ensure that the About action is invoked when the root URL of the site is accessed. What should you do?

A. At line 04 in the Global.asax.cs file, add the following line of code.

routes.MapRoute("Default4Empty", "/", new {controller = "Home", action = "About"});

B. At line 04 in the Global.asax.cs file, add the following line of code.

routes.MapRoute("Default", "", new {controller = "Home", action = "About"});

C. Replace line 05 in the Global.asax.cs file with the following line of code.

routes.MapRoute("Default4Empty", "{controller}/{action}/{id}", new

{controller = "Home", action = "About", id = ""});

D. Replace line 05 in the Global.asax.cs file with the following line of code.

routes.MapRoute("Default", "{controller}/{action}", new {controller = "Home", action = "About"});

Answer: C


QUESTION 35

You create a new ASP.NET MVC 2 Web application.

The following default routes are created in the Global.asax.cs file. (Line numbers are included for reference only.)

01 public static void RegisterRoutes(RouteCollection routes) 02 {

03 routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

5 routes.MapRoute("Default", "{controller}/{action}/{id}", new {controller

= "Home", action = "Index", id = ""});

6 }

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

public ActionResult Index()

public ActionResult Details(int id)

public ActionResult DetailsByUsername(string username)

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

clip_image002The details for a user must to 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 {controller = "Home", action = "DetailsByUsername", id = ""});

B. Replace line 05 with the following code segment.

routes.MapRoute("Default", "{controller}/{action}/{username}", new

{controller = "Home", action = "DetailsByUsername", username = ""}, new

{username = @"w{3,20}"});

C. At line 04, add the following code segment.

routes.MapRoute("Details by Username", "{username}", new {controller = "Home", action = "DetailsByUsername"}, new {username = @"w{3,20}"});

D. At line 04, add the following code segment.

routes.MapRoute("Details by Username", "{id}", new {controller = "Home", action = "DetailsByUsername"}, new {id = @"w{3,20}"});

Answer: C


QUESTION 36

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

The URL with path /Home/Details/{country} will return a page that provides information about the named country.

You need to ensure that requests for this URL that contain an unrecognized country value will not be processed by the Details action of HomeController.

What should you do?

A. Add the ValidateAntiForgeryToken attribute to the Details action method.

B. Add the Bind attribute to the country parameter of the Details action method.

Set the attribute’s Prefix property to Country.

C. Create a class that implements the IRouteConstraint interface.

Configure the default route to use this class.

D. Create a class that implements the IRouteHandler interface.

Configure the default route to use this class.

Answer: C


QUESTION 37

You are implementing an ASP.NET MVC 2 Web application that allows users to view and edit data. You need to ensure that only logged-in users can access the Edit action of the controller.

What are two possible attributes that you can add to the Edit action to achieve this goal? (Each correct answer presents a complete solution. Choose two.)

A. [Authorize(Users = "")]

B. [Authorize(Roles = "")]

C. [Authorize(Users = "*")]

D. [Authorize(Roles = "*")]

Answer: AB


QUESTION 38

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 the request 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.)

A. Add the following attribute to the first Edit action.

[AcceptVerbs(HttpVerbs.Head)]

B. Add the following attribute to the first Edit action.

[HttpGet]

C. Add the following attribute to the second Edit action.

[HttpPost]

D. Add the following attribute to the second Edit action.

[HttpPut]

Answer: BC


QUESTION 39

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.

public ActionResult info()

{

return View();

}

B. Add the following method to the CompanyController class.

public ActionResult Company_Info()

{

return View();

}

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.

Answer: AD


QUESTION 40

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?

A. <%= Html.RouteLink("Test", "test_default", new {area = "test"}, null) %>

B. <%= Html.ActionLink("Test", "Details", "Test", new {area = "test"}, null) %>

C. <a href="<%= Html.RouteLink("Test", "test_default", new {area = "test"}, null) %>">Test</a>

D. <a href="<%= Html.ActionLink("Test", "Details", "Test", new {area = "test"}, null) %>">Test</a>

Answer: B


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