Rahul Khanna

Rahul Khanna

  • NA
  • 236
  • 0

Need help with getting correct answer from duplicate questions

Sep 27 2011 1:27 PM

Hi all,

Please help somebody with correct answer. I am preparing for .net 4 certificaiton exam. I found  many same questions have been repeated with different answer. Its making huge confusion. Please somebody give the correct answer: Below is the list of same repeated question with different answer.

Question Topics User Roles:

QUESTION NO: 1

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

Answer: A

QUESTION NO:  duplicate of 1.

 

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. Dim isMember As Boolean =

Roles.GetUsersInRole ("Administrators").Any()

B. Dim isMember As Boolean =

Membership.ValidateUser ( User.Identity.Name , "Administrators")

C. Dim isMember As Boolean =

Roles.GetRolesForUser ("Administrators").Any ()

D. Dim isMember As Boolean = User.IsInRole ("Administrators")

 

Answer: D

 

Question regarding Mail:

QUESTION NO: 2

You use the ASP.NET Web Site template to create a Web site that will be deployed to multiple

locations. Each location will specify its SMTP configuration settings in a separate file named

smtp.config in the root folder of the Web site.

You need to ensure that the configuration settings that are specified in the smtp.config file will be

applied to the Web site.

Which configuration should you use in web.config?

 

A. <configuration>

<system.net>

<mailSettings>

<smtp configSource="smtp.config"allowOverride="true">

<network host="127.0.0.1" port="25"/>

</smtp>

</mailSettings>

</system.net>

</configuration>

B. <configuration>

<system.net>

<mailSettings>

<smtp configSource="smtp.config"/>

</mailSettings>

</system.net>

</configuration>

C. <configuration xmlns:xdt="http://schemas.microsoft.com/XML- Document-Transform">

<location path="smtp.config" xdt:Transform="Replace"

xdt:Locator="Match(path)">

<system.net />

</location>

</configuration>

D. <configuration>

<location path="smtp.config">

<system.net>

<mailSettings>

<smtp Devilery Method="Network" >

<Network Host = "127.0.0.1" Port="25"/>

</smtp>

</mailSettings>

</system.net>

</location>

</configuration>

 

Answer: B

QUESTION NO: Duplicate of 2

You use the ASP.NET Web Site template to create a Web site that will be deployed to multiple

locations. Each location will specify its SMTP configuration settings in a separate file named

smtp.config in the root folder of the Web site. You need to ensure that the configuration settings

that are specified in the smtp.config file will be applied to the Web site.

Which configuration should you use in web.config?

A. <configuration>

<system.net>

<mailSettings>

<smtp configSource="smtp.config"allowOverride="true">

<network host="127.0.0.1" port="25"/>

</smtp>

</mailSettings>

Microsoft 70-515 Exam

"A Composite Solution With Just One Click" - Certification Guaranteed 116

</system.net>

</configuration>

B. configuration>

<system.net>

<mailSettings>

<smtp configSource="smtp.config" />

</mailSettings>

</system.net>

C. </configuration>

<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">

<location path="smtp.config" xdt:Transform="Replace"

xdt:Locator="Match(path)">

<system.net />

</location>

</configuration>

D. <configuration>

<location path="smtp.config">

<system.net>

<mailSettings>

<smtp deliveryMethod="Network">

<network host="127.0.0.1" port="25"/>

</smtp>

</mailSettings>

</system.net>

</location>

</configuration>

Answer: A

 

Question Regarding: LINQ

QUESTION NO: 3 

You are implementing an ASP.NET application that uses LINQ to Entities to access and update

the database.

The application includes the following method to update a detached entity of type Person.

private NorthwindContext _entities;

public void UpdatePerson(Person personToEdit)

{}

You need to implement the UpdatePerson method to update the database row that corresponds to

the personToEdit object.

Which code segment should you use?

 

 

A. _entities.People.Attach(personToEdit);

_entities.ObjectStateManager.ChangeObjectState(

personToEdit,

EntityState.Modified);

_entities.SaveChanges();

B. _entities.ObjectStateManager.ChangeObjectState(

personToEdit,

EntityState.Added);

_entities.SaveChanges();

C. _entities.People.ApplyCurrentValues(personToEdit);

_entities.SaveChanges();

D. _entities.People.Attach(new Person() { Id = personToEdit.Id });_entities.ObjectStateManager.

ChangeObjectState(

personToEdit,

EntityState.Modified);

_entities.SaveChanges();

 

Answer: A

QUESTION NO: Duplicate of 3

You are implementing an ASP.NET application that uses LINQ to Entities to access and update

the database. The application includes the following method to update a detached entity of type

Person.

private NorthwindContext _entities;

public void UpdatePerson(Person personToEdit)

{

}

You need to implement the UpdatePerson method to update the database row that corresponds to

the personToEdit object.

Which code segment should you use?

A. _entities.People.Attach(personToEdit);

_entities.ObjectStateManager.ChangeObjectState(

personToEdit,

EntityState.Modified);

_entities.SaveChanges();

B. _entities.ObjectStateManager.ChangeObjectState(

personToEdit,

EntityState.Added);

_entities.SaveChanges();

C. _entities.People.ApplyCurrentValues(personToEdit);

_entities.SaveChanges();

_entities.People.Attach(new Person() { Id = personToEdit.Id });

D. _entities.ObjectStateManager.ChangeObjectState(

personToEdit,

EntityState.Modified);

_entities.SaveChanges();

Answer: B

 

Explanation: Question Regarding output Cache Vary By Custom:

QUESTION NO: 4

You are developing an ASP.NET Web application. The application will contain a page that is

customized for various browsers. The application will use output caching to optimize performance.

You need to ensure that the page is cached by browser type and major version only.

Which attribute should you add to the OutputCache directive?

A. VaryByCustom="browser"

B. VaryByCustom="User-Agent"

C. VaryByHeader="browser"

D. VaryByHeader="User-Agent"

Answer: A

QUESTION NO: duplicate of 4

 

You are developing an ASP.NET Web application.

The application will contain a page that is customized for various browsers. The application will

use output cache to optimize performance.

You need to ensure that the page is cached by browser type and major version only.

Which attribute should you add to the OutputCache directive?

 

A. varyByCustom= "browser"

B. varyByCustom= "User-Agentt"

C. varyByHeader= "browser"

D. varyByHeader= "User-Agentt"

 

 

Answer: D

 

Question on Caching:

QUESTION NO: 5

You are developing an ASP.NET Web application. Application data is stored in a Microsoft SQL

Server 2008 database. You configure a connection string named cnnContoso. The application

must cache the data that is returned from the database by using this connection string.

You need to ensure that the application checks the database every 10 seconds. What should you

do?

A. Add the following configuration to the <system.web> section of the web.config file.

<caching>

<outputCacheSettings>

<outputCacheProfiles>

<add name="cnnContoso"

duration="10"/>

</outputCacheProfiles>

</outputCacheSettings>

</caching>

B. Add the following configuration to the <system.web> section of the web.config file.

<caching>

<sqlCacheDependency enabled="true" pollTime="10000">

<databases>

<add name="ContosoDatabase"

connectionStringName="cnnContoso" />

</databases>

</sqlCacheDependency>

</caching>

C. Add the following @ Page directive to pages that query the database.

<%@ OutputCache Duration="10"

VaryByParam="cnnContoso" %>

D. Add the following @ Page directive to pages that query the database.

<%@ OutputCache Duration="10000"

VaryByParam="cnnContoso" %>

Answer: B

QUESTION NO: Duplicate of 5

You are developing an ASP.NET Web application. Application data is stored in a Microsoft SQL

Server 2008 database. You configure a connection string named cnnContoso.

The application must cache the data that is returned from the database by using this connection

string.

You need to ensure that the application checks the database every 10 seconds.

What should you do?

A. Add the following configuration to the <system.web> section of the web.config file.

<caching>

<outputCacheSettings>

<outputCacheProfiles>

<add name="cnnContoso"

duration="10" />

</outputCacheProfiles>

</outputCacheSettings>

</caching>

B. Add the following configuration to the <system.web> section of the web.config file.

<caching>

<sqlCacheDependency enabled="true" pollTime="10000">

<databases>

<add name="ContosoDatabase"

connectionStringName="cnnContoso" />

</databases>

</sqlCacheDependency>

</caching>

C. Add the following @ Page directive to pages that query the database.

<%@ OutputCache Duration="10"

VaryByParam="cnnContoso" %>

D. Add the following @ Page directive to pages that query the database.

<%@ OutputCache Duration="10000"

VaryByParam="cnnContoso" %>

Answer: D

 

 

Question on Area Registration:

QUESTION NO: 6

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

Microsoft 70-515 Exam

"A Composite Solution With Just One Click" - Certification Guaranteed 10

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?

A. Replace line 11 with the following code segment.

context.MapRoute("product_default",

"{area}/{controller}/{action}/{id}",

New With {.area = "product", .controller = "Product",

.action = "Index", .id = ""})

B. Replace line 11 with the following code segment.

context.MapRoute("product_default",

"{area}",

New With {.controller = "Product", .action = "Index", .id = ""})

C. Add the following code segment at line 12.

AreaRegistration.RegisterAllAreas()

D. Add the following code segment to the RegisterRoutes method in the Global.asax.vb file.

AreaRegistration.RegisterAllAreas()

Answer: A

 

QUESTION NO:  Duplicate of 6

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

Microsoft 70-515 Exam

"A Composite Solution With Just One Click" - Certification Guaranteed 10

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?

A. Replace line 11 with the following code segment.

context.MapRoute("product_default",

"{area}/{controller}/{action}/{id}",

New With {.area = "product", .controller = "Product",

.action = "Index", .id = ""})

B. Replace line 11 with the following code segment.

context.MapRoute("product_default",

"{area}",

New With {.controller = "Product", .action = "Index", .id = ""})

C. Add the following code segment at line 12.

AreaRegistration.RegisterAllAreas()

D. Add the following code segment to the RegisterRoutes method in the Global.asax.vb file.

AreaRegistration.RegisterAllAreas()

Answer: C

HTML Action Link:

QUESTION NO: 7

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

Public Class DepartmentController

Inherits Controller

Shared departments As List(Of Department) =

New List(Of Department)

Function Index() As ActionResult

Return View(departments)

End Function

Function Details(ByVal id As Integer) As ActionResult

Return View(departments.Find(Function(x) x.ID = id))

End Function

Function ListEmployees(ByVal d As Department) As ActionResult

Dim employees As List(Of Employee) = GetEmployees(d)

Return View (employees)

End Function

End Class

"A Composite Solution With Just One Click" - Certification Guaranteed 12

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 NO: Duplicate of 7

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

 


Answers (1)