PrepAway - Latest Free Exam Questions & Answers

Author: seenagape

You need to add a route to meet the following requirements

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)
02
03 routes.IgnoreRoute(“{resource}.axd/{*pathInfo}”)
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.
• The details for a user must be displayed when a user name is entered as the path by invoking the
DetailsByUsername action.
• User names can contain alphanumeric characters and underscores, and can be between 3 and 20
characters long.
What should you do?

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.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?

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

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?