Deploying Applications


Now that everything is set in place for unleashing our applications on the world, there's only one task remaining – moving the site to the web and database server(s) that are going to host it. We've already seen that Visual Studio .NET has some features to offer us here, but before taking a quick look at them, we'll see what's available to us with just Web Matrix.

Hosting Websites with Web Matrix

Moving a website to a live environment in .NET is a very simple task; using either the web server built into Web Matrix, or IIS, it's simply a matter of copying the relevant files to a folder that has been web-published (made available via an http:// web address). The .NET Runtime then deals with compiling these files when they're first requested, and executing them, before the web server returns the output back to the browser. If the application makes use of databases, specifically referenced folders for storing files, or other external resources, then settings stored in files such as Web.config may also need amending. Compared to earlier Microsoft technologies, this is a vast improvement. In the past, deploying an application could be fairly torturous as although classic ASP files could similarly just be copied to the target folder, other resources required a more in-depth knowledge to carry out a lot of custom actions.

Deploying the site is only part of the issue, however. Maintaining a server – ensuring it has a permanent connection to the Internet, checking for security updates, and performing all of the other necessary tasks – to enable the smooth running of a hosting environment can take a lot of resources, both time and money. Rather than setting up your own web server so that you can publish applications, there are many other companies that provide this service, allowing you to use their servers. Examples of these can be found on Microsoft's site at the following location:

 www.microsoft.com/vstudio/partners/webhosters/default.asp 

Most of these companies charge a fee for the hosting, and can take care of other tasks such as registering domain names to use for your site. There are other companies that provide hosting for free, as long as you allow them to place advertising banners on your sites.

Obviously, if the web server is located remotely, copying the necessary files to it may not be as simple as dragging and dropping files between the two; they may not be on the same network, there may be security details that need entering, and so on. As mentioned earlier in this book, we have FTP, the File Transfer Protocol. This is designed specifically for copying files to remote locations over the Internet using FTP software. Web Matrix does support this feature, making life much simpler if the provider has already configured the live environment. Even if you're doing the hosting yourself, this method can be used for transferring files to a live server.

To do this from within Web Matrix, select the Add FTP Connection… option from the Workspace menu once you've set up an FTP account. This will bring up the following dialog:

click to expand

Once this has been filled in with the details of either your own FTP server, or those of an account with one of the sites such as those listed by Microsoft, click the OK button, and a new entry will appear in the Workspace pane in Web Matrix. Right-clicking on this will bring up a menu allowing new items to be added directly to this remote location:

Alternatively, files can be dragged and dropped from the local drives to the FTP server from within the tree, copying them to the web server.

As well as the FTP software built into Web Matrix and Windows itself, there are many other utilities available that have been developed for this task, and include such functionality as timed uploads, and automatic retry when errors occur. Two of the most popular tools for this are Cute FTP (www.cuteftp.com), and Bullet Proof FTP (www.bulletproofftp.com), both of which are sold for a small charge and have trial versions that can be downloaded.

Deploying Databases

Deploying databases can quite often be the most difficult part of moving an application to a live environment. This is especially true if we're simply making updates to a database that we've already deployed previously, as the chances are that the data stored in the live version has been updated and needs keeping, while the table structures and stored procedures need overwriting. Solving this problem depends on the specific circumstances encountered, but the general task of transferring a database is a topic worth looking at here.

If we are using a full SQL Server installation, then this can all be done graphically through the Enterprise Manager, given a little experience and patience. If we're using MSDE then the task can be much harder. If we're using MSDE, and have an Enterprise edition of Visual Studio .NET, then the development edition of SQL Server is included with it, along with Enterprise Manager. As SQL Server and MSDE are virtually identical, Enterprise Manager can also be used for administering an MSDE database, making it just as simple as a full-blown SQL Server.

If we don't have access to these tools, then things start to get far more involved as the process has to be carried out manually. This requires a fairly in-depth knowledge of SQL to inform the database of the operation to perform, a copy of the specific file that MSDE uses for storing that particular database's information in, the location where that file is to be placed, and so on. This is one reason that other database engines, such as Microsoft Access, are still being used – not all of them require the same amount of effort in deployment. Microsoft hasn't left developers totally stranded, though. MSDE comes with a command-line tool called osql.exe, which allows SQL statements to be executed against a database server. As well as being able to run SQL code such as SELECT statements that manage data, there are commands such as BACKUP and RESTORE that operate on the database as a whole. More details on these are available in the SQL Books online, which can be downloaded from:

http://www.microsoft.com/sql/techinfo/productdoc/2000/books.asp

There are also articles available on the Web that show how these commands can be put together into tools, and called from osql.exe in order to help us copy our databases around. The first of the following links gives information on the osql.exe tool itself, with the second being an article on backing up databases using it:

 http://msdn.microsoft.com/library/default.asp?url=/library/                                             en-us/coprompt/cp_osql_1wxl.asp http://support.microsoft.com/default.aspx?scid=kb;en-us;241397 

Deployment Packages in Visual Studio .NET

As mentioned, Visual Studio .NET helps us out when it comes to deploying a project. This is done via special types of programs that can be created in the environment – Setup and Deployment Projects. These make the process of transferring our applications to the hosting environment much simpler. Using such a setup project, we no longer have to manually put all of our files in the right location on the server, alter the necessary settings on the machine, amend files such as Web.config by hand so that they point to the right database server, and other such essential, but monotonous tasks.

Instead, we create one of these projects, then drag and drop all of the required files into Visual Studio .NET, along with any other information that is required to make changes to system settings on the servers. When the application that this generates is distributed and run, it presents the user with a standard installation interface, just like the one that was shown while Web Matrix was installing.

Setup projects are especially important if the person who developed the application isn't the one deploying it, or the application is being deployed on a regular basis (possibly to multiple machines). Otherwise, knowledge of all the settings that need to be changed would be required by whoever is installing it, and these changes would have to be made every time the application was installed by hand.

In addition to the deployment packages that we can create in Visual Studio .NET, there are other commercial products available that have been around for much longer, and include greater functionality and ease of use. Two of the most popular examples of these are InstallShield (www.installshield.com) and Wise (www.wise.com), and both have devoted followings.




Beginning Dynamic Websites with ASP. NET Web Matrix
Beginning Dynamic Websites: with ASP.NET Web Matrix (Programmer to Programmer)
ISBN: 0764543741
EAN: 2147483647
Year: 2003
Pages: 141

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net