Eight Key Practices For ASP - Net Deployment
Eight Key Practices For ASP - Net Deployment
Eight Key Practices For ASP - Net Deployment
NET Deployment
by Joydip Kanjilal
his article presents some best practices that you can follow to deploy ASP.NET applications in
production mode. These practices help you avoid problems both during and after deployment.
[assembly: AssemblyVersion("1.0.12.34")]
It's usually best to apply the same version number to all the assemblies in an application during the
build process.
● Resources
An assembly with a strong name can be uniquely identified by a combination of its assembly
version, culture information, and a digital signature.
You can create a strong name for your assembly using the strong name utility (sn.exe) provided by
the .NET framework. The utility requires you to provide the name of a strong name key file as a
parameter. The resulting file is called a "strong-named" file. You can use the sn.exe tool from the
command line to create a strong-named key file as follows:
sn --k MyCompany.snk
When you execute the preceding command, you'll see the output shown in Figure 1.
they're verified at install time rather than at runtime—the .NET framework skips verification at
runtime for GAC-loaded assemblies. The runtime always checks strong-named assemblies to verify
their integrity. .NET refuses to load assemblies that are not trusted or that may have been tampered
with. Note that you must provide a strong name for assemblies you want to install in the GAC.
You place an assembly into the GAC using the GACUtil tool. The following command places
MyProject.dll into the GAC, thus making it globally accessible.
GacUtil /i MyProject.dll
GacUtil /u MyProject.dll
Note that you can even make your strong-named assembly globally accessible without placing it in
the GAC. For this, you need to deploy your assembly using the XCOPY command.
1. Create a new web site called SourceWebSite by selecting File → New → Web Site in the
Visual Studio as shown in Figure 2.
4. Optionally, you can also select the Figure 3. Copy Web Site: Right-click on
SourceWebSite and click on the Copy Web the source web site in Solution
Site option in the solution explorer as shown Explorer and choose Copy Web Site
in Figure 4. from the context menu.
5. You'll see the Copy Web Site screen. You'll see the
files from your source web site listed in the left pane.
If the sites have identically-named subfolders, you can easily synchronize the source and remote
web sites by selecting the "Synchronize Files" option as shown in Figure 9.
Author's Note: When you use XCOPY from Microsoft's Vista OS, you'll see a message
reading: "XCOPY is now deprecated; please use ROBOCOPY." ROBOCOPY stands for
"Robust File Copy." In Vista, you can find more information by typing ROBOCOPY /? at a
command line.
The preceding command copies the SharedWebsite folder and its subdirectories to the c:\DevX
\SourceWebSite folder on the production system. Here's an explanation of the specified options:
You can easily deploy one or more files from the command prompt using the XCOPY command. To
deploy a single file, use a command such as this:
The essence of Click-Once is that you have an application on the client that can detect when
updates are available and download them, allowing you to configure your application to get updates
securely and periodically over the internet. Click-Once provides you with lower costs and
automated updates with no version conflicts! You can use the Click-Once deployment strategy to
provide hot updates to the application, downloading and installing only libraries that have changed.
However, there may be situations when Click-Once does not work the way you expected. For
example, if a client's browser's proxy server has already cached an older version of the deployment
file, that client might not get the updates as expected. Use HTTP content expiration to mitigate such
issues.
● Before you deploy your application, ensure that the Compilation Debug attribute is set to
false in your application's web.config file. When set to true, your application consumes more
memory and processing time, and scripts and images downloaded from the web server do
not get cached locally.
● Build your assemblies in Release mode before you deploy the application to the production
server.
● Ensure that you allow IIS to process dynamic contents by setting the Web Service
Extensions to "enabled" mode.
● Ensure that you have encrypted all configuration data that your application makes use of,
such as connection strings, etc.
● Remember to use Http compression through IIS to compress the size of the rendered
response and improve overall application performance.
Finally, it's advisable to prepare a checklist that lists the deployment steps you have chosen follow;
you can cross-check against that list to ensure that you haven't skipped any steps.
As you can see, there are plenty of strategies for deploying ASP.NET applications to a production
environment. By being aware of the options, selecting the best deployment model for your
application, preparing a checklist, and using it to verify if the best practices documented there, you'll
find that production deployments can go very smoothly.
Joydip Kanjilal has over 10 years of industry experience with C, C++, Java, C#, VB, VC++, ASP.
Net, XML, Design Patterns, UML, etc. He currently works as a senior project leader in a reputable
multinational company in Hyderabad, India, and has contributed articles on .NET and related
techonlogies to www.aspalliance.com.