<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head profile="http://internetalchemy.org/2003/02/profile"> <link rel="foaf" type="application/rdf+xml" title="FOAF" href="http://www.openlinksw.com/dataspace/uda/about.rdf" /> <link rel="schema.dc" href="http://purl.org/dc/elements/1.1/" /> <meta name="dc.title" content="12. Web Application Development" /> <meta name="dc.subject" content="12. Web Application Development" /> <meta name="dc.creator" content="OpenLink Software Documentation Team ; " /> <meta name="dc.copyright" content="OpenLink Software, 1999 - 2009" /> <link rel="top" href="index.html" title="OpenLink Virtuoso Universal Server: Documentation" /> <link rel="search" href="/doc/adv_search.vspx" title="Search OpenLink Virtuoso Universal Server: Documentation" /> <link rel="parent" href="webappdevelopment.html" title="Chapter Contents" /> <link rel="prev" href="vspx.html" title="Virtuoso Server Pages for XML (VSPX)" /> <link rel="next" href="asmxhosting.html" title="ASMX Web Service Hosting" /> <link rel="shortcut icon" href="../images/misc/favicon.ico" type="image/x-icon" /> <link rel="stylesheet" type="text/css" href="doc.css" /> <link rel="stylesheet" type="text/css" href="/doc/translation.css" /> <title>12. Web Application Development</title> <meta http-equiv="Content-Type" content="text/xhtml; charset=UTF-8" /> <meta name="author" content="OpenLink Software Documentation Team ; " /> <meta name="copyright" content="OpenLink Software, 1999 - 2009" /> <meta name="keywords" content="" /> <meta name="GENERATOR" content="OpenLink XSLT Team" /> </head> <body> <div id="header"> <a name="rthwritaspxapps" /> <img src="../images/misc/logo.jpg" alt="" /> <h1>12. Web Application Development</h1> </div> <div id="navbartop"> <div> <a class="link" href="webappdevelopment.html">Chapter Contents</a> | <a class="link" href="vspx.html" title="Virtuoso Server Pages for XML (VSPX)">Prev</a> | <a class="link" href="asmxhosting.html" title="ASMX Web Service Hosting">Next</a> </div> </div> <div id="currenttoc"> <form method="post" action="/doc/adv_search.vspx"> <div class="search">Keyword Search: <br /> <input type="text" name="q" /> <input type="submit" name="go" value="Go" /> </div> </form> <div> <a href="http://www.openlinksw.com/">www.openlinksw.com</a> </div> <div> <a href="http://docs.openlinksw.com/">docs.openlinksw.com</a> </div> <br /> <div> <a href="index.html">Book Home</a> </div> <br /> <div> <a href="contents.html">Contents</a> </div> <div> <a href="preface.html">Preface</a> </div> <br /> <div class="selected"> <a href="webappdevelopment.html">Web Application Development</a> </div> <br /> <div> <a href="webserver.html">The HTTP Server</a> </div> <div> <a href="wsacl.html">Web Services ACL (Access Control List)</a> </div> <div> <a href="vsp1.html">Virtuoso Server Pages (VSP)</a> </div> <div> <a href="vspx.html">Virtuoso Server Pages for XML (VSPX)</a> </div> <div class="selected"> <a href="rthwritaspxapps.html">Deploying ASP.Net Web Applications</a> <div> <a href="#rthprogramming" title="Programming Concepts">Programming Concepts</a> <a href="#rthasp.netdeploymentconf" title="ASP.Net Deployment & Configuration">ASP.Net Deployment & Configuration</a> <a href="#rthaspvsmono" title="The Mono Project">The Mono Project</a> <a href="#rthaspxwalk" title="Migrating ASP.Net Applications to Virtuoso">Migrating ASP.Net Applications to Virtuoso</a> </div> </div> <div> <a href="asmxhosting.html">ASMX Web Service Hosting</a> </div> <div> <a href="blogger.html">Blogging & Weblogs</a> </div> <div> <a href="servphpext.html">Deploying PHP Applications</a> </div> <div> <a href="rthjsp.html">Deploying JSP Applications</a> </div> <div> <a href="perlhosting.html">Perl Hosting</a> </div> <div> <a href="pythonhosting.html">Python Hosting</a> </div> <div> <a href="rubyhosting.html">Ruby Hosting</a> </div> <br /> </div> <div id="text"> <a name="rthwritaspxapps" /> <h2>12.5. Deploying ASP.Net Web Applications</h2> <p>Virtuoso is a CLR host. It is responsible for initializing the runtime, defining the application domain (its runtime boundaries, security settings, etc), and executing user code within such domains. Windows can be used as the development platform, a very developer friendly environment with a rich set of tools, but you will not be restricted to Windows, .NET and IIS to run the assemblies produced. Where .NET is not readily available or desired Virtuoso contains Mono, an open source re-implementation of Microsoft .NET, a vehicle taking .NET cross-platform. </p> <p>The CLR run-time is a part of the Virtuoso process. The Mono run time may be run either as in-process or as out-of-process. Hosted applications can make use of the regular Virtuoso .Net data provider to access Virtuoso SQL data and procedures. Microsoft ASPX files can also be run directly from Virtuoso either from the file system or WebDAV. Each of these capabilities releases you from the Microsoft platforms without compromising your development platform.</p> <p>The Virtuoso CLR hosting is implemented using the VSEI.</p> <table class="figure" border="0" cellpadding="0" cellspacing="0"> <tr> <td> <img alt="The HTTP ASP.Net handler" src="../images/http_handler_aspx.jpg" /> </td> </tr> <tr> <td>Figure: 12.5.1. The HTTP ASP.Net handler</td> </tr> </table> <div class="tip"> <div class="tiptitle">See Also:</div> <p> <a href="rthclr.html#rthclrenvsetdotnet">CLR Host Environment Setup</a> </p> <p> <a href="cinterface.html">VSEI</a> </p> <p> <a href="inprocess.html">In-Process Data Access Client</a> </p> </div> <a name="rthprogramming" /> <h3>12.5.2. Programming Concepts</h3> <p>ASP.Net Web Forms are divided into two sections: the user interface and the application logic. The user interface comprises HTML markup and ASP.Net web controls whereas the application logic contains all the programming code that allows the controls to interact with themselves and the server back-end. This provides the level of abstractions required for dynamic efficient Web application design. The interface can be altered without any backward or forward dependence on the code (logic). The Web Form interface should be created with the .aspx extension. The application logic can be contained in-line within the ASPX application, but developers should strive to keep the code in a separate location known as the "CodeBehind". This is a file that contains the logic (code) for the Web Form which should end in an extension appropriate for the programming language used, such as .vb for Visual Basic or .cs for C#. The CodeBehind can be written in any language for which there is a .Net compiler for. The compiler generates bytecode that can be deployed anywhere the .Net runtime exists.</p> <p>The ASPX Web Form is compiled into an object that takes its place on a tree of controls and classes. The CodeBehind is compiled into an object on this tree when the page is requested. The Web Form must inherit from a "base-class" defined in the CodeBehind class file.</p> <table class="figure" border="0" cellpadding="0" cellspacing="0"> <tr> <td> <img alt="ASPX Web Form class hierarchy" src="../images/rth/writeaspx001.jpg" /> </td> </tr> <tr> <td>Figure: 12.5.2.1. ASPX Web Form class hierarchy</td> </tr> </table> <p>Now we will create a new Web Form containing an HTML heading and an ASP.Net DataGrid control that will display results from the local Virtuoso server. </p> <a name="ex_VirtTest.aspx" /> <div class="example"> <div class="exampletitle">Sample .Net Web Application: VirtTest.aspx</div> <div> <pre class="programlisting"> <%@ Page Language="vb" Inherits="VirtTest" Src="VirtTest.aspx.vb" %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <head> <title>Virtuoso Provider to DataGrid in VB</title> </head> <body> <h1>Simple VB Virtuoso DataBinding Demo</h1> <form id="Form1" method="post" runat="server"> <asp:DataGrid id=DataGrid1 runat="server" DataMember="Customers" BorderColor="silver" BorderWidth="1" CellPadding="2" Font-Name="Tahoma" Font-Size="10pt"> <HeaderStyle BackColor="#2222ff" ForeColor="yellow"/> <PagerStyle Mode="NextPrev" /> </asp:DataGrid> </form> <hr> </body> </html> </pre> </div> </div> <p>On the first line of the file we use the <span class="computeroutput">@ page</span> directive to inherit the CodeBehind class we will create in the CodeBehind file. The source of which can be optionally declared here with the <span class="computeroutput">Src=</span> attribute. Visual Studio makes use of <span class="computeroutput">CodeBehind=</span> for tracking associated source code instead. If either of these two attributes are specified then the .Net runtime will attempt to compile the code into an assembly (DLL) upon first execution if it does not already exist or seems out-of-date. The following code fragment is the CodeBehind, VirtTest.aspx.vb.</p> <p>Now we want some logic behind the Web Form. We have placed a DataGrid control on a web page but we need to supply data to it now:</p> <a name="ex_VirtTest.aspx.vb" /> <div class="example"> <div class="exampletitle">Sample .Net Web Application CodeBehind: VirtTest.aspx.vb</div> <div> <pre class="programlisting"> imports System imports System.Web imports System.Web.UI imports System.Web.UI.WebControls imports System.Web.UI.HtmlControls imports System.Data imports OpenLink.Data.VirtuosoClient Public Class VirtTest Inherits Page Protected WithEvents myConnection As OpenLink.Data.VirtuosoClient.VirtuosoConnection Protected WithEvents myCommand As OpenLink.Data.VirtuosoClient.VirtuosoDataAdapter Protected WithEvents DataGrid1 As System.Web.UI.WebControls.DataGrid Protected WithEvents ds As System.Data.DataSet Private Sub Page_Load(sender As Object, e As EventArgs) Handles MyBase.Load Dim myConnection As new VirtuosoConnection("HOST=noodle:1112;UID=dba;PWD=dba;Database=Demo") Dim myCommand As new VirtuosoDataAdapter("select * from Demo..Customers", myConnection) Dim ds As new DataSet() myCommand.Fill(ds, "Customers") DataGrid1.DataSource=ds.Tables("Customers") DataGrid1.DataBind() End Sub End Class </pre> </div> </div> <p>This file is compiled using the following command (split across lines for readability and would otherwise all be on one line):</p> <div> <pre class="programlisting"> E:\myweb\myapp> vbc /target:library /r:System.dll /r: System.Web.dll /r:System.Data.dll /r:OpenLink.Data.VirtuosoClient.dll /r:System.Xml.dll /out:bin\VirtTest.dll VirtTest.aspx.vb </pre> </div> <p>Once compiled, the resulting DLL library should be in the bin subdirectory of the application root. When the assembly is available in this way the .aspx file does not need to contain the <span class="computeroutput">Src=</span> attribute since there will be no need to compile the CodeBehind. If the <span class="computeroutput">Src=</span> attribute is specified in the .aspx file but the CodeBehind file is not located on the server then an error will be signalled indicating that a required resource cannot be found, because the CodeBehind class is compiled on demand.</p> <br /> <a name="rthasp.netdeploymentconf" /> <h3>12.5.3. ASP.Net Deployment & Configuration</h3> <p>ASP.Net allows multiple Web applications to run on the same machine independently of each other. Web applications have their own directory for components (the ".\bin" directory) and its own XML-based configuration file (the ".config" file). This allows us to develop robust applications using custom configurations and components (or different versions of components) for each one.</p> <div class="note"> <div class="notetitle">Note:</div> <p>The ASP.Net machine-wide configuration is held in machine.config found in the <span class="computeroutput">(C:\Winnt\Microsoft.NET\)Framework\[version number]\CONFIG directory</span> depending on your installation. Applications hosting or making use of .Net may have an application configuration [App Name].config. Web applications store their individual configurations in Web.config stored in the Web application root directory.</p> </div> <p>Each ASP.Net application uses a local assembly cache to hold application specific logic (assemblies, contained in compiled DLLs). The \bin directory located in the application root is the local assembly cache for Web applications. This directory is denied access directly from browsers. This prevents users from downloading or executing any DLLs contained within.</p> <p>When a Web application is started the .Net Framework constructs a new instance of the <span class="computeroutput">System.AppDomain</span> class. When the instance is constructed it creates in-memory shadow copies of the DLLs in the \bin directory. The .Net Framework keeps an in-memory cache (shadow) of all assemblies used so that the actual files (.DLLs) are not locked. The .Net Framework will monitor the original DLL for changes. When changes occur the in-memory cache is updated. Applications already loaded and running with calls in-progress to the old library will continue using the old version so there is no interruption. All new calls to library will be effected, and use the new library. This means that you are free to replace the DLL with new versions as required. Previously with ASP you were required to stop IIS, register the DLL with RegServ32.exe and restart the Web server. </p> <p>When new libraries are added to the .Net Framework for use in any application system wide, such as the Virtuoso Data Provider, these need to be added to the Global Assembly Cache (GAC). This is achieved using the <span class="computeroutput">gacutil.exe</span> utility found in the <span class="computeroutput">Framework\[version number]</span> directory. The <span class="computeroutput">gacutil.exe</span> tool registers the DLL along with its version. One of .Net's strengths is its ability to maintain multiple versions of DLLs for multiple applications. This prevents "DLL-hell"; new DLLs breaking old applications. Applications can also maintain their own local versions of DLLs in their \bin directory.</p> <div> <pre class="programlisting">gacutil.exe /i <full path and file name>.dll</pre> </div> <p>Registers assemblies with the Global Assembly Cache.</p> <div> <pre class="programlisting">gacutil.exe /l</pre> </div> <p>Can be used to list registered assemblies.</p> <p>After registering assemblies using the <span class="computeroutput">gacutil.exe</span> tool you must add an <span class="computeroutput"><add assembly="..." /></span> entry into the <span class="computeroutput"><configuration><system.web><compilation><assemblies> </span> section of the machine.config.</p> <p>The application given in the previous section can be deployed to Virtuoso in the WebDAV repository or directly on file system under the VSPRoot directory. You should copy the directory structure as defined, applications in the root of the new directory and DLLs in a bin subdirectory. A virtual directory must be configured with execute permissions enabled. The application can be tested with a Web browser.</p> <br /> <a name="rthaspvsmono" /> <h3>12.5.4. The Mono Project</h3> <p>The Mono Project is an open source version of the Microsoft.NET development platform. Incorporating key .NET compliant components, including a C# compiler, a Common Language Runtime just-in-time compiler, and a full suite of class libraries, the Mono Project will enable developers to create .NET applications and run them on Windows or any Mono-supported platform. Besides greatly improving the efficiency of development in the open source world, the Mono Project will allow the creation of operating-system-independent programs. Although primarily developed on Linux, Mono is being ported to as many operating systems as possible.</p> <p>Microsoft.NET development tools, which include the C# compiler and Common Language Infrastructure (CLI), let programs written in C# and other languages run on non-Windows operating systems. The Mono Project development platform provides open source developers with a true "build once, deploy anywhere" tool-set taking advantage of the myriad of services enabled by Microsoft.NET.</p> <p>The Mono Project will provide three key elements in a development framework designed to allow developers to quickly create, deploy and run .NET compatible applications on non-Windows platform. A C# compiler extending the GNOME development platform will allow Linux developers to create .NET compatible applications. These developers will also be able to build upon a complete implementation of class libraries compatible with the Microsoft CLI, enabling developers to create end-user applications as well as powerful web services using the database functionality available on open source systems. Portation of Mono yields versions of the Microsoft Common Language Run-Time (CLR) just-in-time (JIT) run-time engine will allow non-Windows systems to run .NET applications built on Windows, Linux or UNIX platforms.</p> <p>The example in the previous section can be run using the CLR hosting ability of Virtuoso, but only with the precompiled assembly which has to be deployed into the Mono/lib directory of the Mono installation.</p> <p>The Virtuoso installer on non-Windows platforms for which there is a port of Mono available installs the latest Mono CLR. This is required for the Virtuoso server to host .Net applications on non-Windows platforms.</p> <p>Only a compiler for C#. Inline ASPX code using C# is a safe way to write and experience ASPX hosted from Virtuoso. Although this goes completely against the programming practice guidelines for .Net</p> <p>The only permissible Application Domain is the Mono application. ASP.Net applications should have their own self containable Application Domain - the ./bin directory. Mono does not support this as of yet. The work around is to place all assemblies into the Mono domain.</p> <br /> <a name="rthaspxwalk" /> <h3>12.5.5. Migrating ASP.Net Applications to Virtuoso</h3> <a name="rthaspxnew" /> <h4>12.5.5.1. Creating a Simple Data Bound Application</h4> <p>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.</p> <ol> <li> <div class="formalpara"> <strong>Launch Microsoft's Visual Studio</strong> <p>Once Visual Studio has been launch it present you with the start page that lets you create a New Project.</p> </div> <table class="figure" border="0" cellpadding="0" cellspacing="0"> <tr> <td> <img alt="Databound Examples using MS Visual Studio" src="../images/rth/vs001.jpg" /> </td> </tr> <tr> <td>Figure: 12.5.5.1.1. Databound Examples using MS Visual Studio</td> </tr> </table> </li> <li> <div class="formalpara"> <strong>Create a new Empty Web Project</strong> <p>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. </p> </div> <table class="figure" border="0" cellpadding="0" cellspacing="0"> <tr> <td> <img alt="Databound Examples using MS Visual Studio" src="../images/rth/vs002.jpg" /> </td> </tr> <tr> <td>Figure: 12.5.5.1.1. Databound Examples using MS Visual Studio</td> </tr> </table> </li> <li> <div class="formalpara"> <strong>Wait for IIS application to be set-up</strong> <p>You will be shown a progress dialogue as Visual Studio contacts your web server creating a new web application there.</p> </div> <table class="figure" border="0" cellpadding="0" cellspacing="0"> <tr> <td> <img alt="Databound Examples using MS Visual Studio" src="../images/rth/vs003.jpg" /> </td> </tr> <tr> <td>Figure: 12.5.5.1.1. Databound Examples using MS Visual Studio</td> </tr> </table> </li> <li> <div class="formalpara"> <strong>Add New Web Form</strong> <p>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. </p> </div> <table class="figure" border="0" cellpadding="0" cellspacing="0"> <tr> <td> <img alt="Databound Examples using MS Visual Studio" src="../images/rth/vs004.jpg" /> </td> </tr> <tr> <td>Figure: 12.5.5.1.1. Databound Examples using MS Visual Studio</td> </tr> </table> </li> <li> <div class="formalpara"> <strong>New Web Form</strong> <p>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.</p> </div> <table class="figure" border="0" cellpadding="0" cellspacing="0"> <tr> <td> <img alt="Databound Examples using MS Visual Studio" src="../images/rth/vs005.jpg" /> </td> </tr> <tr> <td>Figure: 12.5.5.1.1. Databound Examples using MS Visual Studio</td> </tr> </table> </li> <li> <div class="formalpara"> <strong>Add a SqlDataAdapter Control</strong> <p>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.</p> </div> <table class="figure" border="0" cellpadding="0" cellspacing="0"> <tr> <td> <img alt="Databound Examples using MS Visual Studio" src="../images/rth/vs006.jpg" /> </td> </tr> <tr> <td>Figure: 12.5.5.1.1. Databound Examples using MS Visual Studio</td> </tr> </table> </li> <li> <div class="formalpara"> <strong>Choose a Query Type</strong> <p>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.</p> </div> <table class="figure" border="0" cellpadding="0" cellspacing="0"> <tr> <td> <img alt="Databound Examples using MS Visual Studio" src="../images/rth/vs007.jpg" /> </td> </tr> <tr> <td>Figure: 12.5.5.1.1. Databound Examples using MS Visual Studio</td> </tr> </table> </li> <li> <div class="formalpara"> <strong>Generate SQL Statements</strong> <p>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:<span class="computeroutput">select * from Customers</span>.</p> </div> <table class="figure" border="0" cellpadding="0" cellspacing="0"> <tr> <td> <img alt="Databound Examples using MS Visual Studio" src="../images/rth/vs008.jpg" /> </td> </tr> <tr> <td>Figure: 12.5.5.1.1. Databound Examples using MS Visual Studio</td> </tr> </table> </li> <li> <div class="formalpara"> <strong>Advanced Options</strong> <p>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. </p> </div> <table class="figure" border="0" cellpadding="0" cellspacing="0"> <tr> <td> <img alt="Databound Examples using MS Visual Studio" src="../images/rth/vs009.jpg" /> </td> </tr> <tr> <td>Figure: 12.5.5.1.1. Databound Examples using MS Visual Studio</td> </tr> </table> </li> <li> <div class="formalpara"> <strong>View Wizard Results</strong> <p>The next panel confirms all the options selected leaving us to simply complete the wizard.</p> </div> <table class="figure" border="0" cellpadding="0" cellspacing="0"> <tr> <td> <img alt="Databound Examples using MS Visual Studio" src="../images/rth/vs010.jpg" /> </td> </tr> <tr> <td>Figure: 12.5.5.1.1. Databound Examples using MS Visual Studio</td> </tr> </table> </li> <li> <div class="formalpara"> <strong>Back to the main window...</strong> <p>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.</p> </div> <table class="figure" border="0" cellpadding="0" cellspacing="0"> <tr> <td> <img alt="Databound Examples using MS Visual Studio" src="../images/rth/vs011.jpg" /> </td> </tr> <tr> <td>Figure: 12.5.5.1.1. Databound Examples using MS Visual Studio</td> </tr> </table> </li> <li> <div class="formalpara"> <strong>Generate Dataset</strong> <p>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.</p> </div> <table class="figure" border="0" cellpadding="0" cellspacing="0"> <tr> <td> <img alt="Databound Examples using MS Visual Studio" src="../images/rth/vs015.jpg" /> </td> </tr> <tr> <td>Figure: 12.5.5.1.1. Databound Examples using MS Visual Studio</td> </tr> </table> </li> <li> <div class="formalpara"> <strong>Add a DataGrid Control</strong> <p>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. </p> </div> <table class="figure" border="0" cellpadding="0" cellspacing="0"> <tr> <td> <img alt="Databound Examples using MS Visual Studio" src="../images/rth/vs012.jpg" /> </td> </tr> <tr> <td>Figure: 12.5.5.1.1. Databound Examples using MS Visual Studio</td> </tr> </table> </li> <li> <div class="formalpara"> <strong>Table Properties</strong> <p>Configure the DataGrid control by right-clicking on the table and selecting Property Builder.</p> </div> <table class="figure" border="0" cellpadding="0" cellspacing="0"> <tr> <td> <img alt="Databound Examples using MS Visual Studio" src="../images/rth/vs013.jpg" /> </td> </tr> <tr> <td>Figure: 12.5.5.1.1. Databound Examples using MS Visual Studio</td> </tr> </table> </li> <li> <div class="formalpara"> <strong>DataGrid Properties</strong> <p>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. </p> </div> <table class="figure" border="0" cellpadding="0" cellspacing="0"> <tr> <td> <img alt="Databound Examples using MS Visual Studio" src="../images/rth/vs014.jpg" /> </td> </tr> <tr> <td>Figure: 12.5.5.1.1. Databound Examples using MS Visual Studio</td> </tr> </table> </li> <li> <div class="formalpara"> <strong>DataGrid Bindings</strong> <p>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.</p> </div> <table class="figure" border="0" cellpadding="0" cellspacing="0"> <tr> <td> <img alt="Databound Examples using MS Visual Studio" src="../images/rth/vs016.jpg" /> </td> </tr> <tr> <td>Figure: 12.5.5.1.1. Databound Examples using MS Visual Studio</td> </tr> </table> </li> <li> <div class="formalpara"> <strong>Preview</strong> <p>Once the details have been saved the view of the table in the page will be updated to reflect the dataset details.</p> </div> <table class="figure" border="0" cellpadding="0" cellspacing="0"> <tr> <td> <img alt="Databound Examples using MS Visual Studio" src="../images/rth/vs017.jpg" /> </td> </tr> <tr> <td>Figure: 12.5.5.1.1. Databound Examples using MS Visual Studio</td> </tr> </table> </li> <li> <div class="formalpara"> <strong>Page Initialization</strong> <p>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 <span class="computeroutput">.vb</span> 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.</p> </div> <p>These lines of code need to be added by hand:</p> <div> <pre class="programlisting"> SqlDataAdapter1.Fill(DataSet11) DataGrid1.DataBind() </pre> </div> <p>You will find that Visual Studio will offer some assistance in the form of intellisense command-completion while you are typing.</p> <table class="figure" border="0" cellpadding="0" cellspacing="0"> <tr> <td> <img alt="Databound Examples using MS Visual Studio" src="../images/rth/vs018.jpg" /> </td> </tr> <tr> <td>Figure: 12.5.5.1.1. Databound Examples using MS Visual Studio</td> </tr> </table> </li> <li> <div class="formalpara"> <strong>The End Result</strong> <p>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.</p> </div> <table class="figure" border="0" cellpadding="0" cellspacing="0"> <tr> <td> <img alt="Databound Examples using MS Visual Studio" src="../images/rth/vs019.jpg" /> </td> </tr> <tr> <td>Figure: 12.5.5.1.1. Databound Examples using MS Visual Studio</td> </tr> </table> </li> </ol> <br /> <a name="rthaspxmigratevirt" /> <h4>12.5.5.2. Migrating ASP.Net Applications to Virtuoso</h4> <p>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.</p> <ol> <li> <div class="formalpara"> <strong>Locating your ASPX application</strong> <p>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 <span class="computeroutput">http://ash:8888/aspxdemo1/</span> which was physically located in <span class="computeroutput">c:\inetpub\wwwroot\aspxdemo1\</span>. 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.</p> </div> <table class="figure" border="0" cellpadding="0" cellspacing="0"> <tr> <td> <img alt="Migrating ASP.Net Applications to Virtuoso" src="../images/rth/mig001.jpg" /> </td> </tr> <tr> <td>Figure: 12.5.5.2.1. Migrating ASP.Net Applications to Virtuoso</td> </tr> </table> </li> <li> <div class="formalpara"> <strong>Add a Network Place to DAV</strong> <p>From My Network Places in explorer or Network Neighborhood double-click on the Add Network Place shortcut to start the wizard.</p> </div> <table class="figure" border="0" cellpadding="0" cellspacing="0"> <tr> <td> <img alt="Migrating ASP.Net Applications to Virtuoso" src="../images/rth/mig002.jpg" /> </td> </tr> <tr> <td>Figure: 12.5.5.2.1. Migrating ASP.Net Applications to Virtuoso</td> </tr> </table> </li> <li> <div class="formalpara"> <strong>Network service provider</strong> <p>Select the default option. Click next to continue.</p> </div> <table class="figure" border="0" cellpadding="0" cellspacing="0"> <tr> <td> <img alt="Migrating ASP.Net Applications to Virtuoso" src="../images/rth/mig003.jpg" /> </td> </tr> <tr> <td>Figure: 12.5.5.2.1. Migrating ASP.Net Applications to Virtuoso</td> </tr> </table> </li> <li> <div class="formalpara"> <strong>Internet or Network Address</strong> <p>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.</p> </div> <table class="figure" border="0" cellpadding="0" cellspacing="0"> <tr> <td> <img alt="Migrating ASP.Net Applications to Virtuoso" src="../images/rth/mig004.jpg" /> </td> </tr> <tr> <td>Figure: 12.5.5.2.1. Migrating ASP.Net Applications to Virtuoso</td> </tr> </table> </li> <li> <div class="formalpara"> <strong>Name the Network Place</strong> <p>Provide the network place with a meaningful name so we can easily find this location in the future. Click on next to continue.</p> </div> <table class="figure" border="0" cellpadding="0" cellspacing="0"> <tr> <td> <img alt="Migrating ASP.Net Applications to Virtuoso" src="../images/rth/mig005.jpg" /> </td> </tr> <tr> <td>Figure: 12.5.5.2.1. Migrating ASP.Net Applications to Virtuoso</td> </tr> </table> </li> <li> <div class="formalpara"> <strong>Open the Network Place</strong> <p>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.</p> </div> <table class="figure" border="0" cellpadding="0" cellspacing="0"> <tr> <td> <img alt="Migrating ASP.Net Applications to Virtuoso" src="../images/rth/mig006.jpg" /> </td> </tr> <tr> <td>Figure: 12.5.5.2.1. Migrating ASP.Net Applications to Virtuoso</td> </tr> </table> </li> <li> <div class="formalpara"> <strong>Connect to DAV</strong> <p>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.</p> </div> <table class="figure" border="0" cellpadding="0" cellspacing="0"> <tr> <td> <img alt="Migrating ASP.Net Applications to Virtuoso" src="../images/rth/mig007.jpg" /> </td> </tr> <tr> <td>Figure: 12.5.5.2.1. Migrating ASP.Net Applications to Virtuoso</td> </tr> </table> </li> <li> <div class="formalpara"> <strong>Copy the ASPX application to DAV</strong> <p>Once the explorer opens up on the DAV network place we can copy the <span class="computeroutput">aspxdemo1</span> application directory to it.</p> </div> <table class="figure" border="0" cellpadding="0" cellspacing="0"> <tr> <td> <img alt="Migrating ASP.Net Applications to Virtuoso" src="../images/rth/mig008.jpg" /> </td> </tr> <tr> <td>Figure: 12.5.5.2.1. Migrating ASP.Net Applications to Virtuoso</td> </tr> </table> </li> <li> <div class="formalpara"> <strong>Configure Virtual Directory</strong> <p>Now we have to configure a Virtuoso virtual directory. Go to Conductor / Web Application Server / HTTP Hosts Directories. </p> </div> <table class="figure" border="0" cellpadding="0" cellspacing="0"> <tr> <td> <img alt="Migrating ASP.Net Applications to Virtuoso" src="../images/rth/mig009.png" /> </td> </tr> <tr> <td>Figure: 12.5.5.2.1. Migrating ASP.Net Applications to Virtuoso</td> </tr> </table> </li> <li> <div class="formalpara"> <strong>Add Virtual Directory</strong> <p>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.</p> </div> <table class="figure" border="0" cellpadding="0" cellspacing="0"> <tr> <td> <img alt="Migrating ASP.Net Applications to Virtuoso" src="../images/rth/mig010.png" /> </td> </tr> <tr> <td>Figure: 12.5.5.2.1. Migrating ASP.Net Applications to Virtuoso</td> </tr> </table> </li> <li> <div class="formalpara"> <strong>Select DAV Domain template</strong> <p>On the next page select for "Type" the DAV Domain template and click "Next".</p> </div> <table class="figure" border="0" cellpadding="0" cellspacing="0"> <tr> <td> <img alt="Migrating ASP.Net Applications to Virtuoso" src="../images/rth/mig011.png" /> </td> </tr> <tr> <td>Figure: 12.5.5.2.1. Migrating ASP.Net Applications to Virtuoso</td> </tr> </table> </li> <li> <div class="formalpara"> <strong>Configure the Virtual Directory parameters</strong> <p>We must supply a logical path, <span class="computeroutput">/aspxdemo1</span>, 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 <span class="computeroutput">dba</span> using the drop down. To save the changes click on the "Save Changes" button at the bottom of the page.</p> </div> <table class="figure" border="0" cellpadding="0" cellspacing="0"> <tr> <td> <img alt="Migrating ASP.Net Applications to Virtuoso" src="../images/rth/mig012.png" /> </td> </tr> <tr> <td>Figure: 12.5.5.2.1. Migrating ASP.Net Applications to Virtuoso</td> </tr> </table> </li> <li> <div class="formalpara"> <strong>View the ASPX page hosted in Virtuoso DAV</strong> <p>With the virtual directory configured we have only to test that it works as expected. On opening a browser at: <span class="computeroutput">http://localhost/aspxdemo1/WebForm1.aspx</span>, we will see the same output as before.</p> </div> <table class="figure" border="0" cellpadding="0" cellspacing="0"> <tr> <td> <img alt="Migrating ASP.Net Applications to Virtuoso" src="../images/rth/mig013.jpg" /> </td> </tr> <tr> <td>Figure: 12.5.5.2.1. Migrating ASP.Net Applications to Virtuoso</td> </tr> </table> </li> </ol> <div class="note"> <div class="notetitle">Note:</div> <p>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.</p> <p>You will first need to find out what version of the <span class="computeroutput">aspnet_isapi.dll</span> library you have. The simplest way to determine this is by locating the file and right-clicking properties on it from explorer.</p> <p>Assuming the version is 1.0.3705.288, we should enter the following details into the registry if the <span class="computeroutput">HKLM\Microsoft\ASP.NET</span> key is missing (if your version differs change it accordingly):</p> <div> <pre class="programlisting"> [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" </pre> </div> </div> <br /> <br /> <table border="0" width="90%" id="navbarbottom"> <tr> <td align="left" width="33%"> <a href="vspx.html" title="Virtuoso Server Pages for XML (VSPX)">Previous</a> <br />Virtuoso Server Pages for XML (VSPX)</td> <td align="center" width="34%"> <a href="webappdevelopment.html">Chapter Contents</a> </td> <td align="right" width="33%"> <a href="asmxhosting.html" title="ASMX Web Service Hosting">Next</a> <br />ASMX Web Service Hosting</td> </tr> </table> </div> <div id="footer"> <div>Copyright© 1999 - 2009 OpenLink Software All rights reserved.</div> <div id="validation"> <a href="http://validator.w3.org/check/referer"> <img src="http://www.w3.org/Icons/valid-xhtml10" alt="Valid XHTML 1.0!" height="31" width="88" /> </a> <a href="http://jigsaw.w3.org/css-validator/"> <img src="http://jigsaw.w3.org/css-validator/images/vcss" alt="Valid CSS!" height="31" width="88" /> </a> </div> </div> </body> </html>