Deployment of A Website On IIS
Deployment of A Website On IIS
During last few days, I was deploying my application and I faced a lot of issues. I found deploying an application properly is as much as important as developing application. If application is not deployed properly, it can be very harmful to you application Here I want to share my learning to you all. For deployment, first we need to understand IIS, it's request processing and then we'll go for deployment of the website and various configuration available in IIS, their key features, advantages and disadvantages etc..
IIS IIS and URL Processing IIS6.0 Process Model Managing a Virtual directory o Making a Virtual Directory o Virtual Directories Settings Managing a Application Pool o Creating Application pools o Application pools Configurations Deploying application
o o
IIS
IIS at root level, a Windows Service that is responsible for processing requests received on specific ports. For it, a service called the World Wide Web Publishing Service runs on the system. For deploying an application, we cerate a Virtual directory and the convert it into an application. Actually Virtual Directory is nothing more than a configuration entry in IIS for sharing a physical path for access through Web Server.
The complete configuration (with all its settings) is stored in a file, called a metabase, on local system. IIS metabase is a XML -based data store in IIS6.x and it can be configured through IIS management console.
First, IIS examine the requested URL. It also check the port if it is not configured on default port 80,then url also requires port no. If we have a URL "http://webserver/store/books.aspx" then here web server shows the name of Virtual directory and books.aspx is the requested file. Every file extension is registered in IIS and connected with ISAPI extension and every file is connected to a DLL file. Every file extension is connected to ASP.NET runtime are connected with appropriate aspnet_isapi.dll ISAPI extension. these are automatically added at the time of installation. Using this different version of framework are managed (as, ASP.NET 1.0 1.1 and 2.0) and can be configured for every website. IIS 6 is split in several componants:In it a Kernel driver as the picture below is responsible for receiving HTTP requests from the clients then it forwards requests to any process that registers itself for specific URLs. i e any application that
registers with the kernel mode driver can receive HTTP requests without running the whole server. IIS launches worker processes which provide mechanism of Isolation and each worker process runs one or more applications, either ASP.NET based or any other type
WAS monitors each workers process and if one fails it restarts it so that it application doesn't go down abruptly.
We can define separate identity for each worker process ie it allows to configure additional isolation through permissions of the account that's configured for the worker process and these are configured through application pools in IIS management console i e every application pool has itself own worker process and every Virtual Directory can be be assigned to these application pools as I discuss in the last section.Each application pool can run as many application as needed. Application pools allows us to easily configure different web applications to run under different account with different resource usage limits and provide more web application isolation
Read: It is most basic and is mandatory to access the webpage of your application. Run Scripts: It is required for the aspx pages not for the static HTML pages because aspx pages need more permissions sp that they could conceivably perform operations. Execute: This allows the user to run an ordinary executable file or CGI application. This can be a security risk so allow when it is really needed. Write: It allows to add, modify or remove files from the web server. This should never be allowed. Browse: This allows one to retrieve a full list of files in the virtual directory even if the contents of the file are restricted.It is generally disabled.
5. Right Click on the Virtual Directory and go to properties and clock on create to set it as application
S No 1 2
.asmx
.asax
5 6
.ashx .axd
Description These are ASP.NET WebPages These are ASP.NET user controls. It can't be accessed directly, to access it it must be hosted on ASP.net pages. These are ASP.NET web services, which is used for exposing functionality to other applications over HTTP. These are for Glo9bal application file which is used for global events like when user starts the application. These are HTTPHandlers,which allow to process requests without using the fullfledged ASP.NET web-page model. These are used for the trace.axd application extension, which allows to
trace messages while debugging These extn identify that IIS is hosting an .rem and .soap object that can be called by .NET Remoting These files are used by ASP.NET, but that can't be directly called by clientsAlthow,ASP.NET registers them .cs,.csproj,.licx,.config,.resx,.webinfo so that it can explicitly prevent users from accessing these files, regardless of the IIS security settings.
Normally, if we have multiple versions of ASP.NET installed at one point of time, one may want to configure the mappings deffrently in different directories. Documents: This tab allows one to specify the default documents for a Virtual Directory. Like if user just type "http://MyServer/MyApplication" then IIS simply redirect to the user to that default page. If none page is found, IIS will return the HTTP 404 (page not found error). To see and set the default page, in the properties of the Virtual Directories, Click on the documents tab
Custom Errors: This tab allows us to specify an error page that'll be displayed for specific type of HTTP errors (see below picture) .One can use ASP.NET configuration to replace HTTP errors or application errors with custom messages. This only work if the web request makes it to ASP.NET service.
Stability problems: If on a server there are multiple application are running, If all are on same pool then if this pool have any problem the all the application using this pool are going to affected. Memory Leaks: If there is resource intensive application an old application running on a application pool with a memory leak is perfect candidate for regular
recycling. In this case, applications running on different application pool, will not get affected. Security: Security configuration is another main reason for having multiple application pool. Let us ,we want an application that will be able to write some logs on the client computer, then we should have an application pool which should run on LocalSystem's account other might be doesn't need the same so they can on different accounts. Administration: This is also one of the reasons for having separate pools .Might be on a server, there are multiple sites hosted for saparate parties then it doesn't allow to access the resources of another pools.
Note: Recycling an application pool (worker process) means stoppinng the old worker proceses which have already take lots of resources and start new instance of it for the application pool. To create the application pool follow the below steps ( Please keep in mind that IIS should be installed on the machine) 1. Go to run -> type inetmgr then click ok. You will get the following window.
2.
3.
First, if you want to use default settings (use it when you want to create it with new settings) Second, If you want to have a new pool with just same settings as some another pool then you can can select this one and change the template pool from the dropdown (It'll save your time from doing the same settings again)
4. You can configure the application pool by right click on the pool created and select properties
5. You can configure the identity of every application pool by selecting Identity tab from the property window of application pool as above window
Here in the dropdown ,one has three options: Network Service: This account is restricted account with least privileges in the three.This is mainly used for applications that require access to network and need to be accessed from other machines in the network. Local Service: This account is having more restricted than Network service and mainly to be used for services that don,t require additional network access. Local system: Generally this account is not recommended to use, because it is most powerful account of the system. It can perform any action on the local system. so the basic motto , one should provide that much of privilege that the application needed so it can't be hacked easily. you can also configure it as selecting your own user account by specifying the the Windows user name and password for this account.
Deploying Application:
Deploying is nothing more than copying the published code of the application to target machine and configure the environment as needed. this is true for simple application but for application using database or access other resources, one need to perform additional steps. 1. Copy required file to target machine: Check whether all assemblies are in place. If not use install it using gacutil.exe. 2. Create and configure the Database 3. Add IIS file mappings as per requirement 4. Update web.config for any application settings or connection strings etc.
5. Rest settings can be done as per requirement as we discussed above like application pool etc. Hope you all like this article. Please do post your comments it'll help me a lot to improve this article as well as my upcoming articles.
License
This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)
Multiple File Upload With Progress Bar Using Flash and ASP.NET How to use Flash to upload multiple files in a medium-trust hosting environment
10 ASP.NET Performance and Scalability Secrets 10 easy ways to make ASP.NET and AJAX websites faster, more scalable and support more traffic at lower cost
Exploring Session in ASP.Net This article describe about session in ASP.Net 2.0 . Different Types of Session , There Configuration . Also describe Session on Web Farm , Load balancer , web garden etc.
Paging of Large Resultsets in ASP.NET An article about optimization and performance testing of MS SQL Server 2000 stored procedures used for paging of large resultsets in ASP.NET Sign Up to vote for this article Your reason for this vote:
Article Top
You must Sign In to use this message board. FAQ Noise Tolerance
Search
Layout
Per page
Update
FirstPrevNext
Automatic Deploy? pl.2 6:41 12 Jan '09 How to create automatic mechanisms (scripts, .exe, installers, ...) performing ALL the steps you show? Sign InView ThreadPermaLink
Re: Automatic Deploy? Brij 18:52 12 Jan '09 For automatic deploy.You need a wesetup for your project.Check the links First[^] Second[^] Cheers!! Brij Sign InView ThreadPermaLink Missing word? paulo.nascimento Hi there! Great article! : D But something is bothering me. When you explained the Local System account, you wrote: "generally this account is recommended to use, because it is most powerful account of the system" Did you mean "generally this account is NOT recommended to use"? Thanks, Paulo Sign InView ThreadPermaLink Re: Missing word? Thanks Paulo, 5.00/5 (1 vote) 17:54 8 Jan '09 13:17 8 Jan '09
Brij
It was just a typo mistake.I'll update it.Thanks a lot again and if any more things need to update/typo mistake.Please do remind me. Thanks Cheers!! Brij Sign InView ThreadPermaLink My vote of 2 Tom Lennon 22:51 5 Jan '09 It doesn't go into detail on the pitfalls of some of the configurable options of the application pool e.g. recycling the worker process blindly at a regular interval will kill sessions, which will have an impact on high-availability applications. Sign InView ThreadPermaLink 1.00/5 (3 votes) Re: My vote of 2 Brij 1:02 6 Jan '09 Hi Tom,
In a application(anywhere),whenever we take an approach to solve a problem,there is always pros and cons/tradeoffs.So the moto is,to apply the best approach based on the requirement so it can harm very less. Tom Lennon wrote: It doesn't go into detail on the pitfalls of some of the configurable options of the application pool
The topic that is explored here,a entire book can be written.My moto is that,to present it in a consize way keeping in mind the important topics,not to present the sea of contents . Tom Lennon wrote: recycling the worker process blindly at a regular interval will kill sessions, which will have an impact on high-availability applications Now coming to this point,Recycling needs only when there is memory leak on the server,and of course after certain time the server would be choked.I am surpised as you say,it will kill sessions, when server will not be in running condition .Recycling of worker processes is needed for the legacy application deployed on various servers(in a cyclic order),having memeory leaks based on the server health so that the application is always up . Tom Lennon wrote: My vote of 2 Lastly markes doesn't matter,but it shows the way one looks the things Cheers!! Brij Sign InView ThreadPermaLink Re: My vote of 2 [modified] Abhijit Jana 1:20 6 Jan '09 Tom Lennon wrote: It doesn't go into detail on the pitfalls of some of the configurable options of the application pool e.g. recycling the worker process blindly at a regular interval will kill sessions, which will have an impact on high-availability applications. That's True !! But It's does not mean that you will down vote the article. You can give him suggestion/Improvement area that he can add/update the article. But it .
does not means to De-Motivate any author by down voting there article. [Added] ( At least not from those who never writes any articles in CP and down vote some article in his first post ) [/Added] cheers, Abhijit CodeProject.Com MVP modified on Tuesday, January 6, 2009 6:43 AM Sign InView ThreadPermaLink 5.00/5 (6 votes) Fantastic Work Brij Abhijit Jana 19:23 4 Jan '09 This is Excellent . This will really helps beginners who are facing lots of problem to deploy their sites on IIS. Even in forum, I have got lots of question that "How to deploy a web sites ?" . Now this is the best link that we can provide to all of them. Again Good Job !!! Keep it Up !!! cheers, Abhijit Sign InView ThreadPermaLink Re: Fantastic Work Brij Thanks a lot Abhijitn for your comments. Cheers!! Brij Sign InView ThreadPermaLink Very Good Job bbm2k3 1:15 4 Jan '09 Thanks a lot.This is a very good article that explores IIS.Many times i faced a lot of issues in it.It'll help all of us Sign InView ThreadPermaLink Re: Very Good Job Brij 6:20 5 Jan '09 Thanks Cheers!! Brij Sign InView ThreadPermaLink Last Visit: 8:49 31 Aug '09 General News Last Update: 8:49 31 Aug '09 Answer Joke Rant Admin 1 Brij 19:31 4 Jan '09
Question
PermaLink | Privacy | Terms of Use Last Updated: 3 Jan 2009 Editor: Sean Ewington
Copyright 2009 by Brij Everything else Copyright CodeProject, 1999-2009 Web18 | Advertise on the Code Project