Ensurepass

QUESTION 111

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

 

Correct Answer: C

 

 

QUESTION 112

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 }

< font face="Arial"> 

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?

 

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}”, new { controller = “Product”, action = “Index”, id = “” });

C.

Add the following code segment at line 11.

AreaRegistration.RegisterAllAreas();

D.

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

AreaRegistration.RegisterAllAreas();

 

Correct Answer: D

 

 

QUESTION 113

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 {area = “”}, null)

C.

Html.ActionLink(“Home”, “Index”, “Home”, new {area = “Blog”}, null)

D.

Html.ActionLink(“Home”, “Index”, “Home”, new {area = “Home”}, null)

 

Correct Answer: B

 

 

QUESTION 114

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.

void Application_Error(object sender, EventArgs e) {

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

}

D.

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

void Page_Error(object sender, EventArgs e)

{

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

}

 

Correct Answer: B

 

 

QUESTION 115

You are deploying an ASP.NET Web application to a remote server. You need to choose a deployment method that will ensure that all IIS settings, in addition to the Web content, will deploy to the remote server. Which deployment method should you choose?

 

A.

the XCOPY command-line tool

B.

the Copy Web Site tool

C.

the Web Deployment tool

D.

the Publish Web Site utility

 

Correct Answer: C

 

 

QUESTION 116

You use the ASP.NET Web Application template to create an application in a new Visual Studio solution. The project uses types that are defined in a class library project. Source code for the class library is frequently modified. You need to ensure that classes in the Web application project always reference the most recent version of the class library types. What should you do?

 

A.

Add the class library project to the solution. Modify the class library project to add a reference to the Web application project.

B.

Add the class library project to the solution. Modify the Web application project to add a reference to the class library project.

C.

Add a post-build step to the Web application project that copies the most recent version of the class library assembly to the bin folder of the Web application.

D.

Add a post-build step to the class library project that copies the most recent version of the class library assembly to the App_Code folder of the Web application. In the <compilation /> section of the web.config file, add an <assembly /> entry that specifies the location of the class library assembly.

 

Correct Answer: B

 

 

QUESTION 117

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 accou
nt.

 

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)

 

 

QUESTION 118

You are creating an ASP.NET Web site. The site is configured to use Membership and Role management providers. You need to check whether the currently logged-on user is a member of a role named Administrators. Which code segment should you use?

 

A.

bool isMember = Roles.GetUsersInRole(“Administrators”).Any();

B.

bool isMember = Membership.ValidateUser(User.Identity.Name, “Administrators”);

C.

bool isMember = Roles.GetRolesForUser(“Administrators”).Any();

D.

bool isMember = User.IsInRole(“Administrators”);

 

Correct Answer: D

&nbs
p;

 

QUESTION 119

You are creating an ASP.NET Web application. The application must call a WCF service by using a WCF routing service. You need to ensure that the application can invoke the target service by using the router endpoint. What should you do?

 

A.

Add a service reference to the router service. In the client binding configuration, specify the address of the router service.

B.

Add a service reference to the target service. In the client binding configuration, specify the address of the target service.

C.

Add a service reference to the router service. In the client binding configuration, specify the address of the target service.

D.

Add a service reference to the target service. In the client binding configuration, specify the address of the router service.

 

Correct Answer: D

 

 

QUESTION 120

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 : IHttpModule

 

{

 

string footerContent = “<div>Footer Content</div>”;

 

public void Dispose( ) {}

 

}

 

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 CustomModule(HttpApplication app)

{

app.EndRequest += new EventHandler(app_EndRequest); }

void app_EndRequest(object sender, EventArgs e)

{

HttpApplication app = sender as HttpApplication; app.Response.Write(footerContent);

}

B.

public void Init(HttpApplication app) {

app.EndRequest += new EventHandler(app_EndRequest); }

void app_EndRequest(object sender, EventArgs e)

{

HttpApplication app = new HttpApplication();

app.Response.Write(foo
terContent);

}

C.

public CustomModule()

{

HttpApplication app = new HttpApplication();

app.EndRequest += new EventHandler(app_EndRequest); } void app_EndRequest(object sender, EventArgs e)

{

HttpApplication app = sender as HttpApplication; app.Response.Write(footerContent);

}

D.

public void Init(HttpApplication app)

{

app.EndRequest += new EventHandler(app_EndRequest); } void app_EndRequest(object sender, EventArgs e)

{

HttpApplication app = sender as HttpApplication; app.Response.Write(footerContent); }

 

Correct Answer: D

 

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

Instant Access to Try Microsoft 70-515 Free Demo

Comments are closed.