Docsity

Web Development Laboratory - Microsoft Visual Studio 2010, Study notes of Approximation Algorithms

Partial preview of the text

Download Web Development Laboratory - Microsoft Visual Studio 2010 and more Study notes Approximation Algorithms in PDF only on Docsity!

Hands-On Lab

Web Development in Visual Studio 2010

Lab version: 1.0.

Last updated: 12/10/

CONTENTS

  • OVERVIEW
  • EXERCISE 1: USING HTML CODE SNIPPETS IN VISUAL STUDIO - Task 1 – Adding a New ListView to an HTML Page Using an HTML Code Snippet - Task 2 – Creating a Custom HTML Snippet
    • Exercise 1: Verification
  • EXERCISE 2: TRANSFORMING A WEB.CONFIG FILE FOR DEPLOYMENT - Task 1 – Creating a Staging Configuration in Visual Studio - Task 2 – Adding Code to Populate Text Value of EnvName from a Value in the web.config - Task 3 – Adding a Logging Database Connection String to the web.config File - Staging web.config......................................................................................................................... Task 4 – Writing a Transform to Change the Environment and Logging Connection Strings in the - Task 5 – Generating a Transformed web.config File from the Command Line - Task 6 – Generating a Transformed web.config File from Visual Studio
    • Exercise 2: Verification
  • DEVELOPMENT WEB SERVER........................................................................................................... EXERCISE 3: PACKAGING AND DEPLOYING WEB APPLICATIONS FOR THE VISUAL STUDIO - Task 1 – Opening the Project Properties Publish Page and Creating a Package. - Task 2 – Preparing the Web Server for Deployment - Task 3 – Deploying the Package
    • Exercise 3: Verification
  • SERVER (IIS) EXERCISE 4: PACKAGING AND DEPLOYING WEB APPLICATIONS FOR INTERNET INFORMATION - and Create a Package. Task 1 – Opening and the Project Properties Publish Page, Setting the Web Application to Use IIS - Task 2 – Deploying the Package
    • Exercise 4: Verification
  • SUMMARY............................................................................................................................................

 Packaging and deploying a web application to the Visual Studio Development Web Server  Packaging and deploying a web application to the Windows Internet Information Server (IIS)

Estimated time to complete this lab: 60 minutes.

System Requirements

You must have the following items to complete this lab:

 Microsoft Visual Studio 2010  IIS 7.

Setup

All the requisites for this lab are verified using the Configuration Wizard. To make sure that everything is correctly configured, follow these steps.

Note: To perform the setup steps you need to run the scripts in a command window with administrator privileges.

  1. Run the Configuration Wizard for the Training Kit if you have not done it previously. To do this, run the CheckDependencies.cmd script located under the %TrainingKitInstallationFolder%\Labs\WebDevelopment\Setup folder. Install any pre- requisites that are missing (rescanning if necessary) and complete the wizard.

Starting Materials

This Hands-On Lab includes the following starting materials.

 Visual Studio solutions : The exercise provides a Visual Studio solution that you can use as starting point for the lab exercise. You will find the starting point at: %TrainingKitInstallFolder%\Labs\WebDevelopment\Source\Ex01- HTMLCodeSnippets\begin\C#\HTMLLab ◦ HTMLLab.sln: A solution containing a simple web application used as a starting point for Exercise 1 and the subsequent exercises.

Note: For each exercise, there is an End folder which contains the resulting solution you should obtain after completing that exercise.

Note: User will perform appropriate name value replacement in all path references containing tag. Note: To verify that each step is correctly performed, it is recommended that you build the solution at the end of each task.

Next Step

Exercise 1: Using HTML Code Snippets in Visual Studio 2010

Figure 1 Existing Grid View control in Default.aspx

  1. On the Default.aspx page, you will add a ListView control. Place the cursor after closing GridView tag ( **** ) and press the ENTER key. Press the “ < ” key to invoke the completion list.

Figure 2 Completion List

Note: The small icons next to each completion indicate what type of completion it is: Indicates that a completion entry is also a snippet keyword

Indicates a snippet keyword Indicates a completion entry

  1. Select ListView from the completion list and press the TAB key twice to insert the snippet.

Figure 3 The inserted snippet

  1. To progress you will need to add the layout, to put in a temporary placeholder. Enter the following code to define the LayoutTemplate : **XML

**

By selecting the ASP.NET folder and pressing the TAB key, you will see a list of the ASP.NET specific snippets:

You can abort this action by pressing the ESC key. Do not add any more controls to this page at this time.

Task 2 – Creating a Custom HTML Snippet

In this task, you will create a custom HTML snippet for use inside of the Visual Studio 2010 IDE. The new code snippet will create a label control with the preset default values. Any custom Snippets implemented are stored as XML files in a well-known directory.

  1. In Visual Studio 2010 select File | New | File… from the menu to open the New File dialog. In the New File dialog select General from Categories, XML File from Templates and click Add.
  2. To create the structure of the snippet you will use an existing snippet. In the XML file editor, press CTRL + K , CTRL + X to display the snippets list.

Figure 5 Snippets list

  1. Select Snippet from the list. An XML code snippet will be inserted in the file.

Figure 6 XML definition of a code snippet list

**

**

This will add a label control with the ID of AddrBlock.

  1. Using Windows Explorer , navigate to C:\Users\Documents\ folder. Create a sub- folder “Snippets” in the C:\Users\Documents\ folder.

Note: There are two ways to deploy code snippets to the environment. Option1: Save the XML as a .snippet file to the C:\Users\Documents\Visual Studio 10 \Code Snippets\Visual Web Developer\My HTML Snippets\ folder. Visual Studio will automatically find these snippets and make them available for use. Option 2: Save created snippet XML as a .snippet file in some other location and use the Code Snippets Manager to add the snippet to Visual Studio. Snippets added using the Code Snippets Manager will not be available in the auto complete list.

  1. Select the File | Save As menu command. In the File Save As dialog, change the path to C:\Users\Documents\Snippets folder. Change the file name to “AddrBlock”, set the Save as type dropdown list to Snippet Files (.snippet)* and click Save.
  2. Open the Code Snippets Manager by using the Tools | Code Snippets Manager… menu or the CTRL + K, CTRL + B shortcut. The Code Snippets Manager dialog appears.

Figure 7 Code Snippets Manager

  1. In the Language dropdown list, select HTML. Click the Add button to open a Code Snippet Directory dialog.

Figure 9 Snippets folder added to list of snippet locations

Next Step

Exercise 1: Verification

Exercise 1: Verification

You will verify that you can use the custom HTML snippet from Visual Studio 2010 and that the snippet renders the Label control correctly.

  1. Open the source view of the Default.aspx page in the HTMLLab Web Application.
  2. Place the cursor at the end of XML tag of the ListView with the Id Listview1 and press ENTER to create a new line.
  1. Use the CTRL + K, CTRL + X shortcut to open the snippets list. Notice that the Snippets folder you included in the Code Snippets Manager is now also in the list.

Figure 10 Snippets list with the Snippets folder included

  1. Using the mouse or the down arrow, select Snippets from the list and press the TAB key to see the list of snippets available in that folder.

Figure 11 List of snippets in the Snippets folder

  1. Using the mouse or the down arrow key, select the Address Block snippet and press the TAB key. The snippet will expand and add your Address Book element to the page:

Exercise 2: Transforming a Web.Config

File for Deployment

Generally a web application goes through a chain of environments before you it makes it into a Production environment. Some of these environments are Development (the developer’s local machine), Quality Assurance (QA), and User Acceptance Testing (UAT)/Staging/Pre-Production. As applications transition through these environments, various settings in the configuration files must change. In addition to database connection strings many Enterprise scale applications also rely on configuration settings for logging destinations, file drop shares and addresses for service endpoints.

Visual Studio 2010 adds a new web.config transformation model that you can use to automate changes to the web.config file during the deployment of the application when you use MSDeploy to promote your code.

Note: To complete the tasks in this exercise, you must have completed all the tasks in Exercise 1, or use the solution from the %TrainingKitInstallFolder%\Labs\WebDevelopment\Source\Ex02- TransformingWebConfig\begin\C#\HTMLLab folder.

Task 1 – Creating a Staging Configuration in Visual Studio 2010

  1. Open the HTMLLab Web Application completed at the end of the previous exercise.
  2. Select Build | Configuration Manager from the menu. The Configuration Manager dialog appears:

Figure 13 Configuration Manager

  1. Select **** from the Active solution configuration dropdown list to bring up the New Solution Configuration dialog.

Figure 14 New Solution Configuration

  1. In the Name field type “Staging” and from the Copy setting from dropdown list box select Release. Leave the Create new project configurations checkbox checked. Your dialog should look similar to the figure below: