Developing ASP.NET MVC 4 Web Applications 試験
Question No : 1
You are developing an ASP.NET MVC application.
You need to choose the appropriate Visual Studio templates to use for each test goal.
Which Visual Studio Unit Test project templates should you use? To answer, drag the appropriate Unit Test project template to the correct test goal or test goals. Each project template may be used once, more than once, or not at all. You may need to drag the split bar between panes or scroll to view content.
Box 1: Coded UI Test Project
Automated tests that drive your application through its user interface (UI) are known as coded UI tests (CUITs). These tests include functional testing of the UI controls. They let you verify that the whole application, including its user interface, is functioning correctly. Coded UI Tests are particularly useful where there is validation or other logic in the user interface, for example in a web page. They are also frequently used to automate an existing manual test.
Box 2: Unit Test Project
Unit testing is a software testing method by which individual units of source code, sets of one or more computer program modules together with associated control data, usage procedures, and operating procedures, are tested to determine whether they are fit for use. Intuitively, one can view a unit as the smallest testable part of an application.
Box 3: Web Performance and Load Test Project
Box 4: Web Performance and Load Test Project
A load test is a container of Web performance tests and unit tests.
A load test exposes many run-time properties that can be modified to generate the desired load simulation.
Question No : 2
You are developing an ASP.NET MVC application. The application uses a set of custom exceptions to log errors that occur during the execution of an action.
You need to develop a class that implements logging.
Which interface should you implement?
Exception filters are used to apply global policies to unhandled exceptions in the MVC app.
Exception Filters implement either the IExceptionFilter or IAsyncExceptionFilter interface.
Exception filters handle unhandled exceptions, including those that occur during controller creation and model binding. They are only called when an exception occurs in the pipeline.
Question No : 3
You are building an ASP.NET application for a purchasing system.
The application has a method named CalculateBalance in the Purchasing class.
You need to create a unit test for the CalculateBalance method.
Which five actions should you perform in sequence? To answer, move the appropriate actions from the list of actions to the answer area and arrange them in the correct order.
Step 1: Select the Purchasing Project and add a new Unit Test Project.
First we create a Unit Test Project within the current project.
You can turn an existing unit test into an ASP.NET unit test by configuring it, that is, by assigning values to certain of the test's custom attributes. You set these values in the code file that contains the unit test.
All unit tests require the [TestMethod] attribute.
Step 3: Build the solution
Step 4: Run all tests
Step 5: Debug the solution
After you run a unit test, if you chose to edit the test run configuration when you ran the test, you can open the Code Coverage window to see what percentage of the methods in the code that you are testing were covered by your unit tests.
You do not set up testing by creating copies of methods.
Question No : 4
You are developing an ASP.NET MVC application that enables you to edit and save a contact.
The application must not save on an HTTP GET request.
You need to implement the controller.
Which two possible code segments should you use? Each correct answer presents a complete solution.
A: We retrieve the GET and POST methods through this.HttpContext.Request.RequestType.
B: This is the default MVC implementation of having separate methods for GET and POST via function overloading.
Not D: We retrieve the GET and POST methods through this.HttpContext.Request.RequestType, not through this.HttpContext.Request["ActionName"].
Question No : 5
You are developing an ASP.NET MVC application.
The application has a contact view includes a form for editing the displayed contact.
You need to save the Contact object model when the form is posted back to the EditContact method using a POST method request.
Which code segment should you use? Each correct answer presents a complete solution. Choose all that apply.
Question No : 6
You develop an ASP.NET MVC application. The application is configured for claims-based authentication by using Windows Identity Foundation (WIF).
You need to access the claims in the WIF token.
Which code segment should you use?
To Access the Claims
In order to access identity related information, you can run FedUtil. Once you have run FedUtil, your application can access IClaimsPrincipal and IClaimsIdentity using the standard ASP.NET constructs as shown in the following code example:
void Page_Load(object sender, EventArgs e)
// Cast the Thread.CurrentPrincipal
IClaimsPrincipal icp = Thread.CurrentPrincipal as IClaimsPrincipal;
// Access IClaimsIdentity which contains claims
IClaimsIdentity claimsIdentity = (IClaimsIdentity)icp.Identity;
// Access claims
foreach(Claim claim in claimsIdentity.Claims)
Question No : 7
The application includes the following method. (Line numbers are included for reference only.)
When users attempt to retrieve a product from the product page, a run-time exception occurs if the product does not exist.
You need to route the exception to the CustomException.aspx page.
Which line of code should you insert at line 05?
Question No : 8
You are developing a controller for an ASP.NET MVC application that manages blog postings.
The security protection built in to ASP.NET is preventing users from saving their HTML.
You need to enable users to edit and save their HTML while maintaining existing security protection measures.
Which code segment should you use?
Explanation: ValidateInput at Action Method Level
The user can submit Html for this action method successfully with the following code.
public class HomeController : Controller
public ActionResult AddArticle()
public ActionResult AddArticle(BlogModel blog)
Question No : 9
You are developing an ASP.NET MVC application. You plan to use OAuth to authenticate users to the application.
You need to use the correct authentication data in the application.
What should you do? To answer, drag the appropriate data element to the correct location or locations. Each data element may be used once, more than once, or not at all. You may need to drag the split bar between panes or scroll to view content.
Live Connect implements the OAuth 2.0 protocol to authenticate users.
In the authorization code grant flow, the client makes authorization requests by using request_type=code.
The following diagram illustrates how the authorization code grant flow works.
Question No : 10
You are developing an ASP.NET MVC application that will run in a shared environment.
The application requests the user's password, and then uses the password to sign data.
You need to minimize the potential for the password to be discovered by other processes that run in the shared environment.
What should you do?
Application domains provide a unit of isolation for the common language runtime. They are created and run inside a process. Application domains are usually created by a runtime host, which is an application responsible for loading the runtime into a process and executing user code within an application domain. The runtime host creates a process and a default application domain, and runs managed code inside it. Runtime hosts include ASP.NET, Microsoft Internet Explorer, and the Windows shell.
For most applications, you do not need to create your own application domain; the runtime host creates any necessary application domains for you.
However, you can create and configure additional application domains if your application needs to isolate code or to use and unload DLLs.
Question No : 11
You are developing an ASP.NET MVC application to be used on the Internet. The environment does not use Active Directory.
Users must be able to log on to the application to maintain their personal preferences.
You need to use the least amount of development effort to enable users to log on.
What should you do?
Many Web applications require a way to restrict access to some resources (such as specific pages) so that those resources are accessible only to authenticated users. The default Web application project template for ASP.NET MVC provides a controller, data models, and views that you can use to add ASP.NET forms authentication to your application. The built-in functionality lets users register, log on and off, and change their password. For many applications, this functionality provides a sufficient level of user authentication.
Not B: Windows authentication would require an Active Directory.
Windows authentication method works only if the following two conditions exist:
/ You set up your network to use the Kerberos authentication protocol that requires Active Directory.
/ You set up the computers and accounts on your network as trusted for delegation.
Question No : 12
You are developing an ASP.NET MVC application that will be hosted on Microsoft Azure. The application includes the StackExchange.Redis client package. A variable named CacheConnectionConfiguration stores the cache endpoint URL and the password to connect to the cache.
The application must store a user's color selection by using the Azure Redis cache. The cached value must expire after 90 minutes. You need to cache the user's color selection.
How should you complete the relevant code? To answer, choose the appropriate code segment from each list in the answer area.
Box 1: var cache = connection.GetDatabase():
Once the connection is established, return a reference to the redis cache database by calling the ConnectionMultiplexer.GetDatabase method.
Box 2: cache StringSet(“color”, colorSelection,TimeSpan.FromMinutes(90));
The TimeSpanFromMinutes method returns a TimeSpan that represents a specified number of minutes, where the specification is accurate to the nearest millisecond.
Explanation: The following code snippet shows how to set an expiration time of 90 minutes on a key.
// Add a key with an expiration time of 90 minutes
await cache.StringSetAsync("data:key1", 99, TimeSpan.FromMinutes(90));
Question No : 13
You plan a new ASP. NET MVC application.
The application uses the Model-View Controller (MVC) pattern to separate the modeling of the domain, the presentation, and the actions. This separation is based on user input into three separate classes.
You need to diagram the structural relationship between the three classes.
What should you do? To answer, drag the appropriate class to the correct location or locations. Each class name may be used once, more than once, or not at all. You may need to drag the split bar between panes or scroll to view content.
Graphically, MVC can be shown like on image bellow:
Question No : 14
You deploy an ASP.NET MVC Web application to Internet Information Services (IIS). The application has a secure area that provides access to custom reports.
You must develop custom business logic to support the reports.
The custom business logic has the following requirements:
You must be able to quickly modify and deploy updates to the business logic.
You need to develop the custom business logic.
What should you do?
An ASP.NET HTTP handler is the process that runs in response to a request that is made to an ASP.NET Web application.
ASP.NET maps HTTP requests to HTTP handlers based on a file name extension.
Not B: HTTP modules differ from HTTP handlers. An HTTP handler returns a response to a request that is identified by a file name extension or family of file name extensions. In contrast, an HTTP module is invoked for all requests and responses. It subscribes to event notifications in the request pipeline and lets you run code in registered event handlers.
Question No : 15
You are developing an ASP.NET MVC application that delivers real-time game results to sports fans.
The application includes the following code. Line numbers are included for reference only.
The source data for the game results is updated every 30 seconds.
Testers report the following issues with the application:
You need to correct the performance issues.
Which two changes should you make to the code? Each correct answer presents part of the solution.
B: They report delays in seeing the latest game results. This is the output of the GetResults() function. We decrease the Duration in the cache for this function from 3600 to 30. This is one line 12.
A: They report seeing other user's name when they sign in to the application. This is the output of the GetUserInfo() function. We should change the OutputCacheLocation of the caching of this function from Server to Client. This is on line 7.
Note: The OutputCacheLocation.Client option indicates that the content should be cached at the requesting client. Any requests for the same resource made from the same client within the expiry period, will be served out the client’s cache, without a network request being made to the server.
The OutputCacheLocation.Server option indicates that the content will be cached at the origin server. This content will be served for subsequent requests made by the initial client and any other client requesting the same resource within the expiry period.