Deploying Applications to the Web in .NET
In this article you will learn how to Deploy Applications to the Web in .NET.
This article has been
excerpted from book "The Complete Visual C# Programmer's Guide" from the Authors
of C# Corner.
In this article I will explain you about Deploying Applications to the Web
Deploying Applications to the Web in .NET
A few files are required for deploying an ASP.NET application: the *.aspx Web
pages, the *.asmx Web services, the binary file compiled from the code-behind
aspx.cs and asmx.cs files, the local Web configuration file, and the discovery
files for the Web services. Table 26.2 shows the different directories and files
deployed in a Web application.
|ASP.NET Item ||Description |
|Application directory ||The root directory of the application. This directory must be made into an IIS Web application; otherwise the application might not run. |
|<AppName>.aspx ||The URL for bringing up Web forms. |
|<webservice>.asmx file ||The URL for calling a Web service. |
|<webservice>.disco file ||Discovery file for locating a Web service. |
|Web.config file ||Used to override the default configuration into for the server application. |
|\bin directory ||Contains the binary file for Web services and Web Forms. |
Table 26.2: ASP.NET Deployed Files and Directories
Web applications can be deployed using FTP tools such as WSFTP or SecureCRT.
Listing 26.2 shows the files deployed in a sample GuestBook application and the
Listing 26.2: Directory and File Structure of GuestBook Application
GuestBookApp (IIS application directory)
bin (binary directory for Web services and application)
Using the Wizard to Deploy ASP.NET
The Project Wizard really makes your life easy when it comes to deploying an
application to the Web. Begin by choosing Add Project->New Project from the File
menu. Type the name of the setup project in the Name field and double-click Web
Setup Project (see Figure 26.20). This will add a Web setup project to the
Figure 26.20: Choosing a Web Setup Project
Double-click the setup project in the Solution Explorer to bring up the File
System window. Rightclick the Web Application folder and choose Add->Project
Output, as shown in Figure 26.21.
Figure 26.21: Adding Project Files to the Setup Project
This brings up a window in which you can choose the output from the project.
Choose Primary Output to package all the local DLLs and DLL dependencies and
click OK. See Figure 26.22.
Figure 26.22: Choosing Project Output for the Setup
Next, right-click the Web Application folder, and this time choose Add->File and
hold down the CTRL key and click all the files necessary to support your Web
application, as shown in Figure 26.23.
Figure 26.23: Choosing Files to Deploy for the Web Application
When you have finished choosing files, click Open. The File System window should
now look like Figure 26.24.
Figure 26.24: File System Window After Adding Necessary Files
Now compile the setup project from the Build menu. The build will create an .msi
file that you can deploy and run on your Web server to set up your Web
application. The Web setup file will be created in the root of wherever you
created your Web project. If you created the project on your localhost, it will
place the setup under \InetPub\wwwroot\<projectsetup>.
To run the Web setup, double-click the setup.exe file. You'll be prompted
regarding to which virtual directory you would like to install your Web project
as well as a port number, as in Figure 26.25.
Figure 26.25: Web Setup Wizard from setup.exe
After running the installation on your local drive, you'll find the Web
application has installed in the GuestBook directory with the directory
structure in Figure 26.26. Note that this matches the directory structure shown
earlier in Listing 26.2.
Figure 26.26Guestbook Files and Directory Structure
If you had copied the setup files to a Web server and run the setup on that Web
server, it would have created a <projectsetup> folder in the virtual directory
specified in Figure 26.25 and then placed the Web application files and bin
directory in that <projectsetup> folder.
Hope this article would have helped you in understanding
Deploying Applications to the Web in .NET. See other articles on the website on .NET and C#.