Designing and Developing Web Applications Using Microsoft .NET Framework 4: Designing the Application Architecture

  • 10/17/2011

Answers

Objective 1.1: Review

  1. Correct Answer: C

    1. Incorrect: This approach would display the link only to administrators. However, because the processing is performed on the client, users could view the page source, see that the link existed (even though the browser would not render it), and identify the page it linked to.

    2. Incorrect: Setting the Visible property to False on the ASPX page would prevent ASP.NET from rendering the control at all. Therefore, JavaScript would not be able to display the control.

    3. Correct: This approach displays the link only to users who are members of the Administrators group, even if the user views the page source. Because it performs the processing on the server, security is maintained.

    4. Incorrect: This approach would never display the link to a user, even if the user was a member of the Administrators group. Additionally, the HyperLink control does not have a Click event. To initiate a postback when a user clicks a link, you would need to use the LinkButton control.

  2. Correct Answer: A

    1. Correct: This approach blends server-side and client-side programming to provide a responsive user interface. The web server communicates directly with the server hosting the virtual machines because the client would not have authorization.

    2. Incorrect: Although this approach would work, the server would not return a response to the user until after all virtual machines had been provisioned. The lack of responsiveness would be unacceptable to most users.

    3. Incorrect: This approach would work only if the server hosting the virtual machines allowed provisioning requests from the client. However, the server hosting the virtual machines allows provisioning requests only from the web server.

    4. Incorrect: This approach would work if you use JavaScript to initiate web service requests rather than page requests. However, you should not use JavaScript to request webpages unless you intend to display them.

  3. Correct Answer: B

    1. Incorrect: ASP.NET 4.0 web application projects do not allow individual classes to be easily testable. Additionally, ASP.NET 4.0 web applications provide no inherent SoC.

    2. Correct: The MVC architecture provides SoC, which also allows individual classes to be testable.

    3. Incorrect: Silverlight is not designed to create websites.

    4. Incorrect: Like ASP.NET 4.0 web applications, ASP.NET 4.0 websites do not allow individual classes to be easily testable and provide no inherent SoC.

Objective 1.1: Thought Experiment

  1. Bandwidth is not a concern because the site is located on a high-speed intranet, and no client-side processing is performed. Therefore, server processing must be limiting the performance of the site. To improve the performance, increase the server’s processing capabilities by upgrading the server hardware or adding more servers.

  2. With page load times of more than five seconds, the site is already performing unacceptably slowly during peak hours. Adding traffic would cause it to be even slower.

  3. You could use Performance Monitor to record the processing time and bandwidth under the current load, and then multiply that by the expected load to estimate the total requirements. To be even more accurate, you could take the site offline and use load-testing software to generate artificial load on the server, and record the performance information by using Performance Monitor.

  4. You could generate the charts on the client rather than on the server.

  5. You could either generate the charts on the client or use AJAX to replace the chart without reloading the webpage.

  6. Generating charts on the client would reduce the processing requirements of the server. You could use JavaScript, Silverlight, or Flash to render the charts on the client. You could provide the raw data to the client by embedding it as an array in the page itself, or you could create a separate web service and have the client chart component retrieve the data from the web service.

  7. Because the website provides per-customer information, caching the webpages and charts would have no impact on bandwidth and would actually increase page load times. However, you could reduce bandwidth usage and improve page load times by caching static embedded objects, such as the website logo, JavaScript, Flash, and Silverlight objects.

Objective 1.2: Review

  1. Correct Answer: C

    1. Incorrect: Refer to answer C.

    2. Incorrect: Refer to answer C.

    3. Correct: To allow the website to remain online if a web server is restarted, you need to configure two web servers. To isolate the database from a denial-of-service attack, you must place it on a separate, third server.

    4. Incorrect: Refer to answer C.

  2. Correct Answer: A

    1. Correct: The website needs to serve six requests per minute, which is an average of one request every ten seconds. Although the amount of processing time per request varies based on the application, very few applications have requests that take more than ten seconds to process, even on very low-end hardware. The database storage requirement can be met by a single hard disk in a single server. There is no compelling reason to physically separate the web and database servers, so a single server for both roles is the best use of the hardware budget.

    2. Incorrect: Refer to answer A.

    3. Correct: Refer to answer A.

    4. Incorrect: Refer to answer A.

  3. Correct Answer: A

    1. Correct: Although you could use WSDualHttpBinding, NetTcpBinding is more efficient.

    2. Incorrect: NetNamedPipesBinding is intended for communications between processes on the same computer.

    3. Incorrect: WsHttpBinding does not support two-way (duplex) communications.

    4. Incorrect: WSDualHttpBinding meets all the requirements; however, NetTcpBinding is more efficient.

Objective 1.2: Thought Experiment

  1. The company will need to change from NetNamedPipesBinding (which only works between processes on a single server) to NetTcpBinding. If the developer stored the binding configuration in the .config files, this might only require updating the configuration files. If the developer hard-coded the bindings, that code will need to be edited, but it should be a simple change.

  2. The company will need to add a secondary binding type to the logic tier, such as NetTcpBinding.

  3. The company will need to change only the connection string for the data assembly.

  4. The company will need to change the logic tier’s binding type to an open-standards based binding type, such as WsHttpBinding. It will have a minor, but perhaps not noticeable, negative impact on performance.

  5. It’s impossible to say without testing the application to determine how many resources each request requires, how many requests each visitor makes, and how quickly visitors send requests at peak hours. However, most low-end servers can handle tens of thousands of visitors per day.

Objective 1.3: Review

  1. Correct Answer: C

    1. Incorrect: Although a Flash chat client could provide a very rich and responsive user interface, it would be incompatible with some browsers.

    2. Incorrect: As with answer A, Silverlight is incompatible with some browsers.

    3. Correct: Responsiveness is key here, and this approach relies on client-side JavaScript and a separate server process to manage the communications. Because the chat client is running entirely in JavaScript, the server could return a page immediately without waiting for customer service.

    4. Incorrect: Although this approach would work, the server would not return a webpage until after customer service typed a response. Most users are not willing to wait several minutes while a page loads.

  2. Correct Answers: B and D

    1. Incorrect: Silverlight requires client-side installation.

    2. Correct: jQuery, a JavaScript plug-in, meets all these requirements.

    3. Incorrect: VBScript does not work with all common browsers. It natively works only with Internet Explorer, limiting its usefulness in Internet applications.

    4. Correct: Microsoft AJAX, a JavaScript plug-in, meets all these requirements.

  3. Correct Answer: A

    1. Correct: Of these choices, only Silverlight provides GPU acceleration. Flash also provides GPU acceleration.

    2. Incorrect: jQuery works with all common browsers and can be used for simple animations. However, at the time of this writing, it does not support GPU acceleration.

    3. Incorrect: VBScript lacks GPU acceleration and natively works only with Internet Explorer.

    4. Incorrect: Microsoft AJAX works with all common browsers and can be used for simple animations. However, at the time of this writing, it does not support GPU acceleration.

Objective 1.3: Thought Experiment

  1. Their bandwidth usage will increase for two reasons. First, every client who visits the site will need to download jQuery from the server. Second, clients who visit the home page will need to download the relatively large 500 KB Silverlight object.

  2. The easiest way to reduce bandwidth usage is to reference the jQuery library from a CDN, such as that provided by Microsoft. This will also improve page load times for many users. The Silverlight object is very large relative to the size of a typical page; if they reduce the size of that object or remove it entirely, bandwidth usage will be much lower.

  3. JavaScript and jQuery are widely accepted, so they should not pose a problem. However, any browser that does not have Silverlight installed (including mobile devices that cannot currently support it) will be unable to view the virtual tool. This is an easy problem to work around; simply determine whether the browser supports Silverlight, and provide alternate content to browsers without the necessary plug-in.

Objective 1.4: Review

  1. Correct Answers: A and C

    1. Correct: Set the CssClass property (and, optionally, the LoginButtonStyle.CssClass, TextBoxStyle.CssClass, LabelStyle.CssClass, TitleTextStyle.CssClass, and ValidatorTextStyle.CssClass properties) to specify the class assigned to the rendered control in HTML. A web designer can use this class name to associate a set of styles with the control in a CSS style sheet.

    2. Incorrect: When RenderOuterTable is set to true, ASP.NET uses an HTML table to format the control, rather than allowing the control to be formatted by using CSS style sheets.

    3. Correct: Set RenderOuterTable to false to allow a control to be styled by using CSS style sheets.

    4. Incorrect: The LoginButtonType property controls whether the button is styled as a button, an image, or a link. Setting this value does not help you meet the requirements.

  2. Correct Answer: D

    1. Incorrect: Partial classes allow you to add functionality to an auto-generated class. They do not provide any client-server communication capabilities.

    2. Incorrect: An UpdateProgress control displays the progress of updates to an UpdatePanel control. It does not allow you to retrieve string values from a server method.

    3. Incorrect: You could display an updated string value by using an UpdatePanel control. However, the messages would be much larger than if you used a Microsoft AJAX page method.

    4. Correct: A Microsoft AJAX page method allows you to call server methods without transmitting view state. This minimizes the size of the messages sent between the client and the server.

  3. Correct Answer: B

    1. Incorrect: Although you could use jQuery to insert custom HTML into a page after it is rendered, the requirements specify that the control should be rendered on the server.

    2. Correct: HtmlHelper extensions allow you to create custom Html methods that render HTML code as strings. They are rendered on the server but do not require view state, so they are relatively efficient.

    3. Incorrect: Custom server controls provide a great deal of flexibility; however, you can meet the requirements by using an HtmlHelper extension, and an HtmlHelper extension requires less development time.

    4. Incorrect: Custom Web Parts require extra development and consume more client and server resources than an HtmlHelper extension.

Objective 1.4: Thought Experiment

  1. Although there are many ways to display the information, a user control is a good choice if it provides enough flexibility to meet the company’s requirements. User controls are easy to develop, and it would be simple to add multiple instances of a user control to the UpdatePanel container, based on which projects a manager wants to monitor.

  2. An UpdatePanel and Timer will work well to automatically refresh a portion of the page on a regular interval. However, it probably won’t be the most efficient way. A more bandwidth-efficient technique would be to create client-side JavaScript that made web services requests (such as page methods) to a server method to retrieve the raw data about a project, and then render it on the client. This technique reduces bandwidth usage and server load, but increases development time. Additionally, although this technique requires only a few lines of server-side code, it would require dozens of lines of client-side JavaScript, which tends to be more difficult to troubleshoot and maintain. Therefore, the trade-off is not entirely clear, and management would need to weigh the benefits of reduced bandwidth against the additional development costs.

Objective 1.5: Review

  1. Correct Answers: B and C

    1. Incorrect: InProc session state stores session information in the web server’s memory. If a user is sent to a different web server, the web server will create a new session for the user.

    2. Correct: When you use state server-based session state, the web servers store and retrieve session state on a central server. All web servers have access to the same session state information, allowing users to move between servers mid-session.

    3. Correct: When you use SQL Server–based session state, the web servers store and retrieve session state on a database server. All web servers have access to the same session state information, allowing users to move between servers mid-session.

    4. Incorrect: Cookieless session state allows browsers that do not support cookies to participate in a session. It does not provide for centralized session state management, however.

  2. Correct Answers: A and C

    1. Correct: SessionStatePagePersister stores view state data within the session on the server instead of using hidden fields that must be sent back and forth between the client and server. SessionStatePagePersister can be problematic in some applications, but if users open only one page at a time, it can work properly.

    2. Incorrect: Control state stores data in hidden fields, just like view state. Therefore, using control state would not change the size of the pages.

    3. Correct: Disabling view state would completely remove the hidden fields that increase page size. However, it might prevent the application from working properly. Additionally, disabling view state does not disable control state.

    4. Incorrect: Dynamic data controls use view state by default.

  3. Correct Answers: A and D

    1. Correct: By default, ASP.NET uses the InProc session state mode, which stores session state information in memory. Although this is very efficient, it does not allow multiple web servers to share session state. You should use StateServer or SqlServer session states any time you use multiple web servers and store information in session state.

    2. Incorrect: Cookieless session state changes how clients identify the session that they are currently using. However, it does not change how the server stores that session data.

    3. Incorrect: A custom PageStatePersister could change the default view state storage mechanism. However, the default view state mechanism of storing data in hidden fields would work properly with multiple web servers and does not need to be changed.

    4. Correct: Whether you use StateServer or SqlServer session state, you need to synchronize the machine key on all web servers.

Objective 1.5: Thought Experiment

  1. The only feature that will require developer time is the support chat status. Because each web server has an isolated instance of the Application object, changing the status would require either updating the Application[“OnlineSupport”] object on all four servers or writing code to store the support chat status in the database server. Either approach should take only an hour or two of development time (not including testing).

  2. Administrators will not need to make any changes to the user information or inventory features; they should work fine in a web farm environment. Naturally, thorough testing will be required to be confident, however. Each web server will maintain a separate cache, but developing a distributed cache might not be worthwhile. They will need to change the session state configuration to use either a state server or the SQL Server, and then update the machine key on all servers.