Microsoft Developing ASP.NET MVC 4 Web Applications (70-486) Free Practice Test
Question 1
You are preparing to test an ASP.NET application. The application includes the following class. Line numbers are included for reference only.

Data will be imported from another system into the current application. Before importing data, you must run unit tests to validate the data. To be considered valid, the data must meet the following requirements:
You need to create unit tests that fail if the requirements are not met.

How should you complete the relevant code? To answer, select the appropriate code segment from each list in the answer area.


Data will be imported from another system into the current application. Before importing data, you must run unit tests to validate the data. To be considered valid, the data must meet the following requirements:
You need to create unit tests that fail if the requirements are not met.

How should you complete the relevant code? To answer, select the appropriate code segment from each list in the answer area.

Correct Answer:

Explanation:
Box 1: TestClass
The [TestClass] attribute is required in the Microsoft unit testing framework for managed code for any class that contains unit test methods that you want to run in Test Explorer.
Box 2: TestMethod
Set the following attributes for the unit test:
[TestMethod]
All unit tests require the [TestMethod] attribute.
Box 3: Assert.Istrue
The value passed into the GetResults method must be greater than or equal to zero.
Box 4: TestMethod
Box 5: Assert.IsNotNull
The value passed into the GetUserInfo method must not be null.
References: https://msdn.microsoft.com/en-us/library/ms182532.aspx
Question 2
You are developing an ASP.NET Core MVC web application that generates html-based reports each day. The reports are placed in a folder named Results in the root of the application.
The application must run on both Windows and Linux.
You need to ensure that reports can be downloaded.
How should you complete the code? To answer, drag the appropriate code segments to the correct locations. Each code segment 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.
NOTE: Each correct selection is worth one point.

The application must run on both Windows and Linux.
You need to ensure that reports can be downloaded.
How should you complete the code? To answer, drag the appropriate code segments to the correct locations. Each code segment 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.
NOTE: Each correct selection is worth one point.

Correct Answer:

Explanation:
Box 1: PhysicalFileProvider
Box 2: Directory
Code example.
There are three types of IFileProvider Implementations -
Physical File Provider - it is used to access the actual or physical file of the system Embedded File Provider - it is used to access files that are embedded in assemblies Composite File Provider - it is used to provide combine access to the files from one or more providers.
Box 3: Pathstring
Code example:
app.UseStaticFiles(new StaticFileOptions()
{
FileProvider = new PhysicalFileProvider(
Path.Combine(Directory.GetCurrentDirectory(), @"MyStaticFiles")),
RequestPath = new PathString("/StaticFiles")
});
References:
https://jakeydocs.readthedocs.io/en/latest/fundamentals/static-files.html
Question 3
You are developing an application that uses many small images for various aspects of the interface.
The application responds slowly when additional resources are being accessed.
You need to improve the performance of the application.
What should you do?
The application responds slowly when additional resources are being accessed.
You need to improve the performance of the application.
What should you do?
Correct Answer: A
Question 4
An advertising campaign was recently launched. Some of the ads contain a link to products that no longer exist or have IDs that have changed.
You need to ensure that all product links display a product.
Which code segment should you use to configure the route?

You need to ensure that all product links display a product.
Which code segment should you use to configure the route?

Correct Answer: C
Question 5
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?
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?
Correct Answer: C
Explanation: Only visible for TestSimulate members. You can sign-up / login (it's free).
Question 6
You are developing an ASP.NET Core application. You have the following code:

You create a folder named Content in your project. You add a controller action that uses authorization and returns a FileResult object.
The application must meet the following requirements:
Use Kestrel as the server.
Serve static files from the wwwroot folder and publicly cache the files for five minutes.
Serve static from the Content folder to authorized users only.
Serve a default.html file from the wwwroot folder.
You need to configure the application.
How should you complete the code? To answer, select the appropriate options in the answer area.
NOTE: Each correct selection is worth one point.


You create a folder named Content in your project. You add a controller action that uses authorization and returns a FileResult object.
The application must meet the following requirements:
Use Kestrel as the server.
Serve static files from the wwwroot folder and publicly cache the files for five minutes.
Serve static from the Content folder to authorized users only.
Serve a default.html file from the wwwroot folder.
You need to configure the application.
How should you complete the code? To answer, select the appropriate options in the answer area.
NOTE: Each correct selection is worth one point.

Correct Answer:

Explanation:
Box 1: UseStaticFiles
For the wwwroot folder. We serve static files from the wwwroot folder
Box 2: UseStaticFiles
Box 3: UseStaticFiles
Serve static from the Content folder to authorized users only.
Note the two app.UseStaticFiles calls. The first one is required to serve the CSS, images and JavaScript in the wwwroot folder (Box 1), and the second call (box 3) for directory browsing of the content folder Code example:
app.UseStaticFiles(new StaticFileOptions()
{
FileProvider = new PhysicalFileProvider(
Path.Combine(Directory.GetCurrentDirectory(), @"MyStaticFiles")),
RequestPath = new PathString("/StaticFiles")
});
References:
https://jakeydocs.readthedocs.io/en/latest/fundamentals/static-files.html
Question 7
You need to implement client-side animations according to the business requirements.
Which line of code should you use? (Each correct answer presents a complete solution. Choose all that apply.)
Which line of code should you use? (Each correct answer presents a complete solution. Choose all that apply.)
Correct Answer: A,D
Question 8
You manage an application that has a custom API. Your company purchases another company. Employees from the purchased company use their own Microsoft Azure Active Directory (Azure AD).
You need to reconfigure the application to ensure that all users can access the application by using the API. You have the following requirements:
Implement authentication for Azure API management.
Configure the API gateway for proper authorization.
Integrate metrics into one dashboard.
Apply additional restrictions to all roles.
What should you implement? To answer, configure the appropriate options in the dialog box in the answer area.
NOTE: Each correct selection is worth one point.

You need to reconfigure the application to ensure that all users can access the application by using the API. You have the following requirements:
Implement authentication for Azure API management.
Configure the API gateway for proper authorization.
Integrate metrics into one dashboard.
Apply additional restrictions to all roles.
What should you implement? To answer, configure the appropriate options in the dialog box in the answer area.
NOTE: Each correct selection is worth one point.

Correct Answer:

Explanation:
Box 1: Groups
Add an external Azure AD group
After you enable access for users in an Azure AD instance, you can add Azure AD groups in API Management. Then, you can more easily manage the association of the developers in the group with the desired products.
To configure an external Azure AD group, you must first configure the Azure AD instance on the Identities tab by following the procedure in the previous section.
You add external Azure AD groups from the Groups tab of your API Management instance.
Box 2: Policies
Policies are applied inside the gateway which sits between the API consumer and the managed API. The gateway receives all requests and usually forwards them unaltered to the underlying API. However a policy can apply changes to both the inbound request and outbound response.
Box 3: Application Insights
Application Insights is an extensible Application Performance Management (APM) service for web developers on multiple platforms. Use it to monitor your live web application.
Box 4: Role-Based Access Control (RBAC)
Apply additional restrictions to all roles.
Azure API Management relies on Azure Role-Based Access Control (RBAC) to enable fine-grained access management for API Management services and entities (for example, APIs and policies).
References:
https://docs.microsoft.com/en-us/azure/api-management/api-management-howto-aad
https://docs.microsoft.com/en-us/azure/api-management/api-management-howto-policies
https://docs.microsoft.com/en-us/azure/api-management/api-management-role-based-access-control
Question 9
You are developing an ASP.NET MVC application that uses forms authentication. The application uses SQL queries that display customer order data.
Logs show there have been several malicious attacks against the servers.
You need to prevent all SQL injection attacks from malicious users against the application.
How should you secure the queries?
Logs show there have been several malicious attacks against the servers.
You need to prevent all SQL injection attacks from malicious users against the application.
How should you secure the queries?
Correct Answer: B
Explanation: Only visible for TestSimulate members. You can sign-up / login (it's free).
Question 10
You are developing an ASP.NET Core MVC web application that provides assets to external websites including images, JavaScript scripts and text files.
The external websites must be able to make full use of assets provided to them by the web application, including JavaScript asynchronous HTTP requests.
Pages that refer to the images and text files do not load. External websites are unable to use assets.
You need to resolve the issues.
What should you do?
The external websites must be able to make full use of assets provided to them by the web application, including JavaScript asynchronous HTTP requests.
Pages that refer to the images and text files do not load. External websites are unable to use assets.
You need to resolve the issues.
What should you do?
Correct Answer: B
Explanation: Only visible for TestSimulate members. You can sign-up / login (it's free).
Question 11
You are developing an ASP.NET MVC application that processes payments for an online retailer The retailer provides a .NET assembly that contains a class named Retail EventSource That derives from the EventSource class.
The RetailEventSource class has a method named SuspiciousTransaction that returns True when the order originates from a system that differs significantly from the system that usually performs orders. The RetailEventSource class also has a field named PaymentProcessed that stores the event identifier for a payment-processed event.
Events must be written only when the event source is in a state where writing events is valid You need to create a derived type that contains the method to raise a PaymentProcessed event

The RetailEventSource class has a method named SuspiciousTransaction that returns True when the order originates from a system that differs significantly from the system that usually performs orders. The RetailEventSource class also has a field named PaymentProcessed that stores the event identifier for a payment-processed event.
Events must be written only when the event source is in a state where writing events is valid You need to create a derived type that contains the method to raise a PaymentProcessed event

Correct Answer:
