14.5.4.Migrating ASP.Net Applications to Virtuoso

Creating a Simple Data Bound Application

This section will describe how to use the MS Visual Studio to create an application using as much drag and drop as possible. We want to create a table of data in a web page from a database.

  1. Launch Microsoft's Visual Studio. Once Visual Studio has been launch it present you with the start page that lets you create a New Project.

    Figure14.18.Databound Examples using MS Visual Studio

    Databound Examples using MS Visual Studio

  2. Create a new Empty Web Project . From the templates select a new Empty Web Project found in the Visual Basic Projects type. You must also select a location on an IIS web server.

    Figure14.19.Databound Examples using MS Visual Studio

    Databound Examples using MS Visual Studio

  3. Wait for IIS application to be set-up. You will be shown a progress dialogue as Visual Studio contacts your web server creating a new web application there.

    Figure14.20.Databound Examples using MS Visual Studio

    Databound Examples using MS Visual Studio

  4. Add New Web Form. When the application-space has been configured on the web server you will be returned to the main Visual Studio windows. Now we must create our page. Right-click on the project name in the Solution Explorer and select Add New Web Form.

    Figure14.21.Databound Examples using MS Visual Studio

    Databound Examples using MS Visual Studio

  5. New Web Form. The Add New Item option will appear, automatically selecting the "Web Form" item to add. Supply a name for the page and click Open to begin.

    Figure14.22.Databound Examples using MS Visual Studio

    Databound Examples using MS Visual Studio

  6. Add a SqlDataAdapter Control. With the fresh "Web Form" we can start. From the ToolBox double-click on the SqlDataAdapter in the Data panel. This will start the Data Adapter Configuration Wizard . After reading the description on the first panel click on the Next button. You will be asked to choose your connection. Assuming that you have access to a Northwind database hosted in MS SQLServer you can either make use of an existing connection to it or configure a new one using the New Connection button. Pressing the New Connection button will present the normal OLEDB dialogues for creating a new datasource. Once a data connection has been selected press Next to continue.

    Figure14.23.Databound Examples using MS Visual Studio

    Databound Examples using MS Visual Studio

  7. Choose a Query Type. The next panel will ask how the data adapter should access the database. For simplicity we will stick with the default of Use SQL Statements. Press Next.

    Figure14.24.Databound Examples using MS Visual Studio

    Databound Examples using MS Visual Studio

  8. Generate SQL Statements. At this point you can either type a SQL statement if you know exactly what you are looking to get back from the database, or you can use the Query Builder to point-and-click to your data. In our case we will retrieve everything from the Customers table using a simple query:select * from Customers .

    Figure14.25.Databound Examples using MS Visual Studio

    Databound Examples using MS Visual Studio

  9. Advanced Options. Click on the Advanced Options button. Unselect the top checkbox. This will also unselect the other two automatically. We will not be performing any updates in this example. OK the advanced options, upon return to the main dialogue press the Next button to continue onwards.

    Figure14.26.Databound Examples using MS Visual Studio

    Databound Examples using MS Visual Studio

  10. View Wizard Results. The next panel confirms all the options selected leaving us to simply complete the wizard.

    Figure14.27.Databound Examples using MS Visual Studio

    Databound Examples using MS Visual Studio

  11. Back to the main window... When the wizard finishes and returns you to the main Visual Studio window you will see that two controls have been added to the Web Form. The connection control has been automatically generated to support the Data Adapter.

    Figure14.28.Databound Examples using MS Visual Studio

    Databound Examples using MS Visual Studio

  12. Generate Dataset. Before we can display anything on the page we need to form a Dataset. Right-click on the SQLDataAdapter1 control you previously added and select Generate Dataset. Defaults on the displayed dialog are all sufficient. After verifying them click the OK button to generate the dataset.

    Figure14.29.Databound Examples using MS Visual Studio

    Databound Examples using MS Visual Studio

  13. Add a DataGrid Control. Now we need to show the dataset that we are fetching from the database. We will use a simple DataGrid for this. Open the toolbox in the Web Forms panel and double-click on the DataGrid control. This add the control to the page and will display a table on the web page view.

    Figure14.30.Databound Examples using MS Visual Studio

    Databound Examples using MS Visual Studio

  14. Table Properties. Configure the DataGrid control by right-clicking on the table and selecting Property Builder .

    Figure14.31.Databound Examples using MS Visual Studio

    Databound Examples using MS Visual Studio

  15. DataGrid Properties. You can adjust most properties of the table such as colours, fonts, borders, etc. You can control paging aspects that will be taken care of automatically by the control, you only need specify the number of results per page. For now we only want to adjust the most important aspects of the table, where the data comes from.

    Figure14.32.Databound Examples using MS Visual Studio

    Databound Examples using MS Visual Studio

  16. DataGrid Bindings. From the first General properties panel you must select the DataSource, DataMember, and select the Data key field (especially important for updatable tables). These properties may be selected via the drop-downs on the panel, allowing you to select the now-familiar controls configured earlier. Once configured, press the OK button to save the changes.

    Figure14.33.Databound Examples using MS Visual Studio

    Databound Examples using MS Visual Studio

  17. Preview. Once the details have been saved the view of the table in the page will be updated to reflect the dataset details.

    Figure14.34.Databound Examples using MS Visual Studio

    Databound Examples using MS Visual Studio

  18. Page Initialization. We are very nearly finished. The controls are all ready to be used, however, the final touch is to edit our Page_Load function. Double-click on the empty part of the web page view in Visual Studio and the associated .vb file will be opened. This is the file containing the actual code. You will be automatically placed at the Page_Load function. This is the page initialization section where will need to instruct the DataAdapter to fill with data, and then instruct the DataGrid to bind to that data.

    These lines of code need to be added by hand:

    SqlDataAdapter1.Fill(DataSet11)
    DataGrid1.DataBind()
    

    You will find that Visual Studio will offer some assistance in the form of intellisense command-completion while you are typing.

    Figure14.35.Databound Examples using MS Visual Studio

    Databound Examples using MS Visual Studio

  19. The End Result. Next we will set the project's initial start-page by right-clicking on the form name in solution explorer and selecting Set as Start Page option. Finally we can run the project using the start button at the top. The project will automatically be built and a browser window launched automatically. Admire your results. When finished, on closing the browser windows you will automatically return to Visual Studio.

    Figure14.36.Databound Examples using MS Visual Studio

    Databound Examples using MS Visual Studio

Migrating ASP.Net Applications to Virtuoso

The previous section showed us how to build a very basic web application using an ASPX data-bound control. Now we will host this same application in Virtuoso demonstrating that IIS is no longer required for ASPX application deployment.

  1. Locating your ASPX application. Use explorer to locate the ASPX application you want to move away from IIS and re-deploy under Virtuoso. The previous section created the application in the IIS virtual directory represented by http://ash:8888/aspxdemo1/ which was physically located in c:\inetpub\wwwroot\aspxdemo1\ . We can simply copy this directory and place it somewhere under either the VSP root directory or WebDAV. We will copy the application to a location in WebDAV for a local Virtuoso server.

    Figure14.37.Migrating ASP.Net Applications to Virtuoso

    Migrating ASP.Net Applications to Virtuoso

  2. Add a Network Place to DAV. From My Network Places in explorer or Network Neighborhood double-click on the Add Network Place shortcut to start the wizard.

    Figure14.38.Migrating ASP.Net Applications to Virtuoso

    Migrating ASP.Net Applications to Virtuoso

  3. Network service provider. Select the default option. Click next to continue.

    Figure14.39.Migrating ASP.Net Applications to Virtuoso

    Migrating ASP.Net Applications to Virtuoso

  4. Internet or Network Address. Here you specify the URL of DAV on the Virtuoso server. We are using Virtuoso on the local machine but this could be anywhere on the Internet. Click next to continue.

    Figure14.40.Migrating ASP.Net Applications to Virtuoso

    Migrating ASP.Net Applications to Virtuoso

  5. Name the Network Place. Provide the network place with a meaningful name so we can easily find this location in the future. Click on next to continue.

    Figure14.41.Migrating ASP.Net Applications to Virtuoso

    Migrating ASP.Net Applications to Virtuoso

  6. Open the Network Place. On the final panel of the wizard there is a checkbox to "Open this network place when I click Finish" that we will leave checked. Click Finish to continue and open the DAV directory.

    Figure14.42.Migrating ASP.Net Applications to Virtuoso

    Migrating ASP.Net Applications to Virtuoso

  7. Connect to DAV. When you attempt to connect to DAV you will be prompted for a User name and Password. These will be whatever you entered during the installation, possibly both dav, in which case type dav in both fields and press the OK button to continue.

    Figure14.43.Migrating ASP.Net Applications to Virtuoso

    Migrating ASP.Net Applications to Virtuoso

  8. Copy the ASPX application to DAV. Once the explorer opens up on the DAV network place we can copy the aspxdemo1 application directory to it.

    Figure14.44.Migrating ASP.Net Applications to Virtuoso

    Migrating ASP.Net Applications to Virtuoso

  9. Configure Virtual Directory. Now we have to configure a Virtuoso virtual directory. Go to Conductor / Web Application Server / HTTP Hosts & Directories.

    Figure14.45.Migrating ASP.Net Applications to Virtuoso

    Migrating ASP.Net Applications to Virtuoso

  10. Add Virtual Directory. The "folder" icon for the hosts defined will list all mappings currently present for the Virtuoso server. Click on the "New Directory" link to continue.

    Figure14.46.Migrating ASP.Net Applications to Virtuoso

    Migrating ASP.Net Applications to Virtuoso

  11. Select DAV Domain template. On the next page select for "Type" the DAV Domain template and click "Next".

    Figure14.47.Migrating ASP.Net Applications to Virtuoso

    Migrating ASP.Net Applications to Virtuoso

  12. Configure the Virtual Directory parameters. We must supply a logical path, /aspxdemo1 , in this case. We must also supply the physical path that this represents, we can either type in the DAV location or use the Browse button to the find the directory under DAV. The WebDAV checkbox will correctly already be checked. For now we will also set to Allow Directory Browsing, and Override execution permissions in WebDAV. Finally we must set the VSP Execution user to dba using the drop down. To save the changes click on the "Save Changes" button at the bottom of the page.

    Figure14.48.Migrating ASP.Net Applications to Virtuoso

    Migrating ASP.Net Applications to Virtuoso

  13. View the ASPX page hosted in Virtuoso DAV. With the virtual directory configured we have only to test that it works as expected. On opening a browser at: http://example.com/aspxdemo1/WebForm1.aspx , we will see the same output as before.

    Figure14.49.Migrating ASP.Net Applications to Virtuoso

    Migrating ASP.Net Applications to Virtuoso

[Note] Note:

If ASPX hosting is attempted on a machine that never had IIS installed it is possible that ASP.NET is not configured, although required. The Virtuoso installer will take care of this for you in most cases but if you run into problems you may want to confirm that ASP.NET is configured correctly. You will have to use the regedit utility to edit the registry, changing a search-path so System.Web.dll can find aspnet_asapi.dll. Always exercise caution whenever editing the registry as invalid data can prevent your machine from operating properly.

You will first need to find out what version of the aspnet_isapi.dll library you have. The simplest way to determine this is by locating the file and right-clicking properties on it from explorer.

Assuming the version is 1.0.3705.288, we should enter the following details into the registry if the HKLM\Microsoft\ASP.NET key is missing (if your version differs change it accordingly):

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\ASP.NET]
     "RootVer"="1.0.3705.288"
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\ASP.NET\1.0.3705.288]
     "Path"="C:\WINDOWS\Microsoft.NET\Framework\v1.0.3705"
     "DllFullPath"="C:\WINDOWS\Microsoft.NET\Framework\v1.0.3705\aspnet_isapi.dll"