CODEDIGEST
Home » Articles
Search
 

Technologies
 

Sponsored links
 

CodeDigest Navigation
 

Technology News
No News Feeds available at this time.
 

Community News
No News Feeds available at this time.
 
Deploying ASP.Net Applications

By Satheesh babu
Posted On AUG 16,2008
Article Rating:
Average Rating: 5
No of Ratings: 1
No of Comments: 3
Category: ASP.Net
Print this article.

Deploying ASP.Net Applications

Introduction

As an ASP.Net developer, we are always focusing on learning new ideas on design and development which made us to have less knowledge on deployment of applications in production. This article targets developer community to have some of the rudimentary knowledge on deployment of ASP.Net application on IIS 6.0. After reading this article user will be familiar in,

Ø       Virtual Directories and Creating it.

Ø       Application Pools, Creating Application Pools and why it is used?

Ø       Use of service accounts in App Pools.

Ø       Web.Config Settings and using Web.Config Settings for debugging errors.

Ø       Common hindrance we may possibly face during deployment and resolutions.

It is assumed that the user is logged in to the server or connected to the server through Remote Desktop Connection and the user has enough permission to do the deployment. This article was originally published here.


Prepare the application for deployment

We can use the Web Deployment plug-in for Visual studio 2005 given by Microsoft for creating Web deployment projects for 2.0 Applications, where we can compile in release mode for 1.1 applications for deployment. See the reference section for more details on Web Deployment plug-in. Copy the application to a folder location where the application is needs to be deployed on the server. Make all Web.Config changes like updating connection strings, if there is any appsettings values changes corresponding to production environments, etc.


Virtual Directory

An IIS Virtual Directory is essentially an alias to the physical directory. The IIS Virtual Directory is a directory name which may be accessed from the Internet to access the physical directory on the server.

Most common way of creating virtual directory is done by 2 ways,

1.      Using IIS Manager.

2.      Using Windows Explorer.

Using IIS Manager:

We can open IIS manager in 3 ways,

Ø       Type Inetmgr in RUN.

Ø       Open Control Panel > Administrative tools > Internet Information Services.

Ø       Right click My Computer, click Manage and expand Internet Information Services.

Creation:

On doing any of the above approach will bring us the IIS manager.

1.      Expand the local computer node, right click the Website under which you want to deploy the application and click New > Virtual Directory. It will bring a dialog like below Figure 1,

Figure 1 - Create Virtual Directory

                                                     

 Click Next.

2.      It will bring next window for entering “Alias” for our websites. See Figure 2.

Figure 2 - Virtual Directory Alias

 

Type the alias name you like to assign for the applications virtual directory. I have used “test” for this article. Click Next.

3.      It will bring a window for linking our website physical directory with virtual directory like below Figure 3,

Figure 3 - Physical Directory Path

Browse to the location and select the website folder as in the figure. Click Next.

4.      This will bring the window for specifying access permissions for the users. Select appropriate permissions. Refer Figure 4.

Figure 4 - Virtual Directory Access Permission

  

I haven’t changed the default setting in this window as this permission is more than enough to run most of the applications. Click Next.      

5.      Click Finish. Thus we have created the virtual directory. 

Using Windows Explorer:                          

1.      Browse to the folder location where you copied the application and right click the folder and click “Sharing and security”.

2.      Open “Web Sharing” tab and select “Share this folder” which will ask for Alias. Type an Alias name click OK and click OK again. Thus we have created virtual directory through windows explorer.


Configure ASP.Net version:

Sometimes the server we are deploying may have both 1.1 and 2.0 framework installed. So we need to configure the applications to use appropriate framework. It can be done through the ASP.Net tab of virtual directory property box like in the below Figure 5.

Figure 5 - ASP.Net tab

If it is 2.0 Application, select 2.0.xxxxx version else 1.1.xxxx.


Application Pools:

Application Pools a.k.a App Pools is introduced with IIS 6.0 to isolate websites into a group called Application Pools. Refer “Things to note” section for the different versions of IIS and their associated operating systems. Also, we can say application pools are a group of one or more URLs that are served by a worker process, means applications running in a single app pools runs in same worker process w3wp.exe, thus providing a boundary so that if one application fails it doesn’t hinder other applications running on other app pools. So as a good practice a highly confidential, secured website can be assigned with a separate app pool. Also we can use app pools to troubleshoot applications by isolating it to a separate application pools, if we suspect that it creates problem. By using an application pool, we can have specific configuration settings to a worker process that services a group of applications or single application that is running under the App Pool. For example, you can configure worker process recycling and several other configuration options to match the needs of each application. We will see this in detail in coming sections.

With this introduction to App pools we will move to our subject matter, creating App pools in IIS 6.0.

Creation:

A new application pool can be created using IIS manager.

Steps:

1.      Open IIS manager.

2.      Expand local computer node. Right click Application Pools node click New> Application Pool like below Figure 6.

Figure 6 - New App Pool

                  

 It will open a dialog to create new app pool like the below Figure 7.

Figure 7 - App Pool ID                         

 

Type a Pool ID for the app pool, the best practice to give identity is choosing name relevant to the applications hosted. For example, if the app pool hosts Shopping cart site let the pool identity as ShoppingCartPool so that it can be easily identified as opposed to AppPool #1, 2, etc. Under Application pool settings> select “Use default settings for new application pool”. Selecting “Use existing application pool as template” will prompt as to select an existing app pool as template so that same setting is applied for the newly creating app pool.

3.      Click OK. Thus a new application pool is created with default configurations




Customizing App pools:

By default, Application pools is configured to use Network Service Account to service the request. At times we will end in a situation where we should use a separate account for servicing the request for different reasons. There are other configuration settings which some times need to be optimized which are really done in exceptional situations. The coming sections will answer these things and take us through on accomplishing this.

Steps:

1.      Right click the App pool you have created (Test Pool) in this example and click Properties. It will bring a dialog like below figure 8.

Figure 8 - App Pool Property Recycling tab

                                          

Recycling tab is opened with default settings like above. Periodic recycling of your application pools is recommended that helps to clean up memory fragmentation, memory leaks, abandoned threads and other disorders. Keep in mind that when an application pool recycles, session state information stored in-process is lost for that pool, but other pools are not affected. ASP.NET, however, does allow you to store your session state outside the worker process, so that session information is not lost during a recycle. It’s better to choose this time should fall when there is less number users accessing the site. We can recycle the worker process based on number of requests, memory usages.

2.      Moving to Performance tab. Refer Figure 9.

Figure 9 - App Pool Property Performance tab

              

When the application does not receive request for certain amount of time it is said to be idle so this setting allow us to free up the occupied resource from the server after the specified time given here. Consider changing Request queue limit if your application receives thousands request per second to mitigate Server busy messages. Most of the time Enable CPU monitoring is not used. Web garden setting should not be changed from 1, this specifies the number of worker process required to process the request for an app pool.

3.      Next tab “Health” tab for configuring the health i.e. the availability of the application can be configured. Refer Figure 10.

Figure 10 - App Pool Property Health tab

    

 Enable pinging, causes IIS to automatically query a worker process to see if it is responsive utilizing network bandwidth. Enable rapid-fail protection helps to disable the app pool for specified number of failures occurred in the worker process. Startup time limit and shutdown time limit are self explanatory and failing to satisfy those condition falls under failure for rapid fail protection.

4.      The “Identity” tab is where we can configure the worker process identity. Refer below Figure 11.

Figure 11 - App Pool Property Identity tab

 

The predefined setting’s default is to use network service account which is a less privileged account for security purposes. The other account that can be pre configured is Local Service and LocalSystem account. Before making the App pool to use custom account known as Service accounts we will explore what and why it is used.


Service Accounts:

It is identity of the App pool under which it services the request. It is account that has very less privileges on the machine so as to reduce the security risk and loop holes. There can be several reasons to opt for custom service account over the Network service account. Some of the reasons are:

Ø       We can have different access controls for different applications on the local and network resources such as fileservers, etc.

Ø       It is also a mode of isolating one application from another by giving a separate identity so other applications cannot access the resource of another application.

Ø       We can prevent any accidental or deliberate changes to the access controls or permissions associated with the general purpose Network Service account from affecting your application.

See reference section for creating new service account.

One think to note here is, if our site uses database then make sure that the custom service account has the required access to the database.

Configuring Custom service account with App Pool:

In the above Figure select Configurable> type the service account id, password and enter. It will ask for password confirmation like below figure, Refer Figure 12. Click OK.

Figure 12 - Configure service account

After doing this restart the App pool by stopping and starting it again.

Associating Site with App Pool:

We need to associate our site with the App pool we created. It can be done by right clicking the site virtual directory (Test in our case) and property. Select the TestPool from Application pool drop down in “Home Directory” tab as in the Figure 13. Click Apply and OK.

Figure 13 - Associating site with App Pool

 

Thus we are at the end of the process and we need to do a smoke test for the application verification.


Possible Errors:

Error:

Service unavailable.

Resolution:

This is one of the ever green errors often we use to get due to many reasons mostly because of service accounts. The common problem will be this account might not be a member of IIS_WPG group on the server or check IIS_WPG group have Read & Execute, List Folder Contents, and Read permissions to the Web site directories. So pre check with a network admin who is creating the service account for you whether the account has all the required permissions on the server.

Error:

An error has occurred while establishing a connection to the server.  When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (Provider: TCP Provider, error: 0 - A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.)

Resolution:

Again there may be several reasons most common will be check the service account has access to the Sql Server. This error occurs even if you are not using Sql server 2005 i.e. the same error occurs even if you use Sql Server 2000. Similar error occurs if there is any problem in connection string too.

Error:

It is not possible to run different versions of ASP.NET in the same IIS process. Please use the IIS Administration Tool to reconfigure your server to run the application in a separate process.

Resolution:

When we host multiple versions of ASP.net in single server we may get this error in event log. The problem might be a application pool will be associated with 2 different application that uses different frameworks. So isolating this application into a different App Pools will solve the problem.


Things to note:

This section highlights some of the important things to consider when we are deploying the application.

1.      Make sure the Web.Config setting is perfect, such as connection strings, App setting values, check <compilation debug="false"/> because setting it to true causes the application to be processed slow, memory consumption is more, scripts and images downloaded from the WebResources.axd handler are not cached.

2.      To trouble shoot the error if occurred use <CustomErrors> section in Web.Config and make sure you are reverting back the original settings so that whenever any error.

3.      If we are running multiple versions of ASP.net on the same webserver don’t use aspnet_regiis utility with –i switch to register the ASP.net with the IIS, instead use –s switch and register it for the particular site because using –i switch is going to update entire IIS with the current version of ASP.net you are registering leaving the existing application configuration affected. For example: Aspnet_regiis –s W3SVC/1/ROOT/Test

4.      By default IIS does not allow dynamic contents like ASP\ASP.NET to be processed by IIS. So to allow this, Open IIS manager click Web Service Extensions and Allow the Web Service Extensions if it is disabled as shown in the Figure 14. If there is no extensions for processing say ASP.net 2.0 application, we can add a new web service extension by clicking “Add a new Web service extension” link shown in the figure. Read more on MSDN on how to add web service extensions in IIS 6.0.

5.      The following are the operating systems and the versions of IIS packed with it.

Ø       Windows 2000 à IIS 5.0

Ø       Windows XP à IIS 5.1

Ø       Windows 2003 à IIS 6.0

6.      Inputs from PrabhuRajan[Refer Comments in ASPAlliance.Com]

There are some places, were Firewall is Mandatory and it cannot be disabled. In such condition, after giving appropriate Permission. Next step is to enable the Web Server(Http) in LAN Settings of the Firewall.

1.      Goto Start à Run à type 'Firewall.cpl'.

2.      Goto Advanced tab, in Local Area Network setting à Click Settings.

3.      After clicking Settings, you will get the list of services. Check WebServer(Http) is checked or not.

4.      After checking WebServer only, your WebSite can be accessed from Other Machines.

 

Figure 14 - Web service Extensions

Reference:

Web Deployment Project

Create new service account

Microsoft Support center

 

Conclusion:

As a web developer we should have the rudimentary knowledge on deploying the web application in the production and so this article will fulfill this anticipation. Checkout Microsoft’s KB articles for more support on Errors and resolutions. Happy Coding!!!           

Similar Articles
You can contribute to CodeDiget.Com:
Donate to CodeDigest.com
Article Feedback
Comments
Check that you are u
Check that you are using the correct dmaion username format for converter. In our network we use format but converter hates that. It requires the use of dmaion\username instead. If you use the wrong credential format it will give this error as well.
Good
The above artical is good and it is also useful for the asp.net developers because i am facing a lot of issues with my asp.net application in IIS when number of concurrent connections are reached. Now i hope ican solve atleast upto some extent. This is very good if you said the more information regarding application pool identity, number of concurrent connections support by system configuration wise.
not given proper information
can u please tell me how to make connection pooling in 5.1 IIS version using asp .net??