EXAM 70-486 STUDY NOTES–PART 3

Question # 1  You are implementing an ASP.NET page that allows users to design basic two-dimensional shapes. A shape is represented by a Shape class in your application’s code. As users change the dimensions of a shape, your page sends a post back to the server to recalculate the shape’s area and perimeter.
You want to use the ViewState object to save a Shape instance across page post backs. Which attribute should you apply to the Shape class? Choose the correct answer

  1. Serializable
  2. ContractClass
  3. CLSCompliant
  4. DataObject

You should ensure that the Shape class is serializable by applying the Serializable attribute to the class

If the class is not serializable, it cannot be stored in a page’s view state, which is represented by the server-side ViewState object. A page’s view state is stored as an encrypted string in a hidden input field and written to the browser. When a page posts back to the server, the data in the hidden input field is used to repopulate the server-side ViewState object.
You should not apply the CLSCompliant attribute to the class. This attribute indicates that a type is common language specification (CLS)-compliant. This has no effect on the ability to store instances of a type in the ViewState object.
You should not apply the ContractClass attribute to the class. This attribute allows you to designate a separate class that supplies the code contracts for an interface. This has no effect on the ability to store instances of a type in the ViewState object.[

Question# 2

You must manage the survey state so that the survey will always resume at the correct location.
What technology should you use?

  1. Cookie
  2. QueryString
  3. InProc Session State
  4. SQL Server Session State
  5. State Server Session State

StateServer Session State is the best option in this scenario. StateServer session state makes the state information available to all web servers in the web farm. StateServer session runs as a Windows service and would help to minimize database traffic.

  • You should not use a cookie. The requirements state that the user must always resume at the correct location. Cookies are stored on the client, so the application would not be able to track the user’s progress if they switched to a different device.
  • You should not use InProc Session State because this mode stores session state with the ASP.NET worker process and is not valid in a web farm configuration.
  • You should not use SqlServer Session State. It does support a web farm configuration, but is not a valid option because it would not minimize database traffic.

Question # 3  You are a senior application developer working on an ASP.NET web application. One of the pages contains a custom tab control, for which you need to remember which tab is selected by the user between round trips to the server.
You need to eliminate user and developer control over the inner-working of the tab widget.
Which state management technique should you choose? 

  1. ViewState
  2. Control State
  3. Cookies
  4. Hidden Field

Explanation:

Control state is the better option for storing custom control data between server trips. Because control state cannot be turned off by developers at the page level, it is more reliable to store control-state data . Look into this  StatckoverFlow post

Cookies can be used to store small amounts of information, such as in this case. However, some users might disable them on their browsers and render the control nonfunctional.

Viewstate can be overriden at a page level so we can not use that as that is the requirement.
You can store page-specific information in a hidden field. In this scenario, a hidden field is not an option because, when designing such controls, you need to keep security in mind. Hidden fields can be tampered with.The information in the hidden field can be seen while viewing the page source.

 

Question# 4

You create an Azure worker role service. When the role is stopping, you must execute a process named Cleanupexe before the role is actually stopped.You need to add a method to the role. Which code segment should you use?

Explanation

we should use the second snippet of code .The OnStop method is called when a role is being stopped. Within the body of the method, you should first call the Start method of the Process class to start the Cleanup.exe process. The Start method returns a Process instance. You should call the WaitForExit method of that instance to block the current thread until the Cleanup.exe process completes. Finally, you should call the base OnStop method to notify Azure that your role-cleanup functionality is complete.

Question# 5  You deploy a web application to an Azure Web role. An unmanaged executable named Migrate.exe exists in the application’s bin directory.
You need to ensure that Migrate.exe runs when the role starts but before the application begins processing requests.  What should you do?

Explanation

You should add this markup to the WebRole element in the service definition file:
<Startup> <Task commandLine=”Migrate.exe” taskType=”simple”/> <IStartup>
This markup allows you to define a startup task for an Azure role. Whenever the role starts, the executable or script represented by the command Line attribute of the Task element runs.

Question# 6  You create an Azure worker role service. When the role is starting, you must execute a process named Initialize.exe before the role is actually started. Once the process completes, the role must continue to run. You need to add a method to the role. Which code segment should you use?

Explanation

You should use second snippet in list .

The OnStart method is called when a role is being started. Within the body of the method, you should first call the Start method of the Process class to start the Initialize.exe process. The Start method returns a Process instance. You should call the WaitForExit method of that instance to block the current thread until the Initialize.exe process completes. You should then call the base OnStart method to notify Azure that your role-initialization functionality is complete. Finally, you should return true from the method to indicate that the startup functionality completed successfully so that the role instance does not immediately stop.

Question# 7 

You are responsible for configuring an Azure worker role for your team’s application. Before a new instance of the worker role becomes available, a license key value must be added to the registry.
You have already created a batch file named SetLicense.cmd and a registry file called SetLicense.reg. Both files have been added to the appropriate project in Visual Studio. The batch file contains the necessary commands for importing the registry key.
What should you do? (Choose all that apply.)

Explanation

You should add the following configuration:

and

The Service Definition file has support for executing one or more startup tasks. Adding a task element that calls the SetLicense.cmd batch file with executionContext set to elevated will cause the registry entry to be added.
You should also change the Copy to output Directory property for SetLicense.cmd and SetLicense.reg to “Copy Always.” to ensure that the SetLicense.cmd file and SetLicense.reg file are deployed with the application.
Calling Process.Start(“SetLicense.cmd”) does not meet the requirement of adding the license key before the worker role instance becomes available and would also require the entire role to run with an elevated execution context. Unnecessarily running the instance with an elevated execution context is a violation of least privilege.

Question# 8 Your company deploys its applications to Azure. You create a startup task that will change some configurations before a role starts. What will happen if an unhandled error is thrown in the startup task?

  1. The startup is cancelled and the role does not start.
  2. The startup role consumes the error during its load.
  3. The startup task attempts to run as a background task, if possible.
  4. The OnStop method automatically runs.

Explanation: The correct answer is first option. The startup is cancelled and the role does not start. The task will actually stop processing and return a non-zero value.
If the startup task causes an unhandled error, the role stops in a failure and the task will not complete successfully. Therefore, the startup role will not consume the error during its load. In addition, because the task will stop in error, the OnStop method in the role wi II not even be reached.
Finally, the startup task will not run as a background task because the task will stop processing.

 

Question# 9  You are a senior application developer at your company. You want to create an AppCmd.exe command to clear the provider list.
You need to write the code to accomplish this task.
Which code should you use?

Explanation:

we should use the second snippet of code in the list.

AppCmd.exe is an IIS command-line tool that helps you configure objects on the web server, such as configuring site and application pools. You can start and stop sites, start, stop, and recycle application pools, and create and configure sites, applications, application pools, and virtual directories.
The following command is not correct because it enables anonymous authentication instead:

 

Question#10  You are creating an ASP.NET MVC application. You plan to deploy the application on a three-server web farm. User session state must be maintained between requests. The application must preserve the session ID for all links that use application-relative paths. The application must not embed the session ID in the URL.
You need to configure session state.
Which configuration should you use? 

Explanation :

You should go with StateServer mode with cookieless option to false.By setting the mode attribute of the sessionState element to StateServer, you allow session state to be stored in memory in the ASP.NET state service. You can specify the machine and port that hosts the service by using the stateConnectionString attribute. By using the ASP.NET state service, you allow session state to be stored in a single place for all browser sessions. By setting the cookieless attribute of the sessionState element to false, you cause the session ID to be persisted in the memory of the user’s browser rather than in the URL.

Question#11 You have an on-premise application that must broadcast one-way messages to five Azure Worker role instances. You have decided to use the Azure Service Bus for sending the messages from the on-premise application to the Azure Worker roles.
Which Service Bus Relay Binding should you use? 

  1. NetTcpRelayBinding
  2. WebHttpRelayBinding
  3. BasicHttpRelayBinding
  4. NetEventRelayBinding

You should use NetEventRelayBinding. The NetEventRelayBinding allows for publishers to broadcast one-way messages to multiple subscribers using the Azure Service Bus.
You should not use BasicHttpRelayBinding. The BasicHttpRelayBinding is used to communicate with services that adhere to the WS-I Basic Profile 1.1. It is comparable to the WCF BasicHttpBinding.
You should not use NetTcpRelayBinding. The NetTcpRelayBinding is an efficient bi-directional binding. Relayed and Hybrid connection modes are supported. The relayed connection mode routes all traffic through the service bus with no direct connection between the client and the service. The hybrid connection mode begins the connection in relay mode and then attempts to switch to a direct connection if possible. It is comparable to the WCF NetTcpBinding.

Question# 12 You are designing a web application that uses a WCF service. The service exposes endpoints that are able to communicate with ASMX-based web services.

You need to use a binding that meets these criteria by default.

Which binding should you use? Choose the correct answer

MsmqlntegrationBinding

WSFederationHtthpBinding

BasicHttpBinding

NetHttpBinding

Explanation:

You should use BasicHtthinding. BasicHttpBinding is the binding that WCF can use
to expose endpoints that are able to communicate with ASMX-based Web services
and clients. It conforms to WS-I Basic Profile 1.1.

WSFederationHttpBinding does not meet the conditions. This is a secure and
interoperable binding that supports federated security.

MsmqlntegrationBinding maps Microsoft Message Queuing messages to WCF
messages.

NetHttpBinding is a binding that is used for consuming HTTP or WebSocket services
that uses binary encoding by default.

 

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *