Microsoft TS: Web Applications Development with Microsoft .NET Framework 4 Sample Questions:
1. 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?
A) Replace line 10 with the following code segment.
context.MapRoute("product_default", "area}",
B) Add the following Code segment to the Register Routes in Global.asax.cs file.
AreaRegistration.RegisterAllAreas();
C) Replace line 10 with the following code segment.
context.MapRoute("product_default", "{area}/{controller}/{action}/{id}", new {area = "product", controller = "Product", action = "Index", id = ""});
D) Add the following code segment at line 11
AreaRegistration.RegisterAllAreas();
2. 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 second Edit action.
[HttpPut]
C) Add the following attribute to the second Edit action.
[HttpPost]
D) Add the following attribute to the first Edit action.
[HttpGet]
3. You are creating an ASP.NET Web application that uses the SqlMembershipProvider.
You plan to test locally and deploy to multiple production servers.
You need to ensure that each deployed application accesses the same production database in Microsoft
SQL Server.
Which two actions should you perform? (Each correct answer presents part of the solution. Choose two.)
A) Modify the connection string in the web.config file to specify the names of the production server and
database.
B) Run the aspnet_regsql command to create the database on the appropriate SQL Server computer.
C) Right-click App_Data in your Visual Studio 2010 project, click Add, and select New Item to create the SQL Server database on the appropriate SQL Server computer.
D) Modify the web.release.config file to transform the connection string to specify the names of the production server and database.
4. You are implementing an ASP.NET Web site.
The site allows users to explicitly choose the display language for the site's Web pages.
You create a Web page that contains a DropDownList named ddlLanguage, as shown in the following code
segment.
<asp:DropDownList ID="ddlLanguage" runat="server" AutoPostBack="True"
ClientIDMode="Static" OnSelectedIndexChanged="SelectedLanguageChanged"> <asp:ListItem Value="en">English</asp:ListItem> <asp:ListItem Value="es">Spanish</asp:ListItem> <asp:ListItem Value="fr">French</asp:ListItem> <asp:ListItem Value="de">German</asp:ListItem>
</asp:DropDownList>
The site contains localized resources for all page content that must be translated into the language that is
selected by the user.
You need to add code to ensure that the page displays content in the selected language if the user selects
a language in the drop-down list.
Which code segment should you use?
A) protected override void InitializeCulture() {
Page.Culture = ddlLanguage.SelectedValue;
}
B) protected void SelectedLanguageChanged(object sender, EventArgs e) {
Page.UICulture = ddlLanguage.SelectedValue;
}
C) protected override void InitializeCulture() {
Page.UICulture = Request.Form["ddlLanguage"];
}
D) protected void Page_Load(object sender, EventArgs e) {
Page.Culture = Request.Form["ddlLanguage"];
}
5. State management
You have to store user data of 200 KB in an object.
Which state management technique to use:
A) Hidden Field
B) Cookie
C) ViewState
D) Server session
Solutions:
Question # 1 Answer: B | Question # 2 Answer: C,D | Question # 3 Answer: B,D | Question # 4 Answer: C | Question # 5 Answer: D |