Difference between application pool and appdomain

Source: Internet
Author: User
I saw a lot of people asking what's the differences between application pool and appdomain in ASP. net. first of all, application pool is a concept in IIS, but appdomain is a concept in. net. you can write your own program to use 2 or more appdomaines. I did a test with the iis7 Asp.net 2.0 on my Vista computer. here is the test code:

Public partial class _ default: system. Web. UI. Page
{
Protected void page_load (Object sender, eventargs E)
{
String Info;
Info = "current process name:" + process. getcurrentprocess (). processname + "</BR> ";
Info + = "current process ID:" + process. getcurrentprocess (). ID + "</BR>"; Info + = "current application domain:" + appdomain. currentdomain. friendlyname + "</BR> ";
Info + = "current application domain base dir:" + appdomain. currentdomain. basedirectory + "</BR> ";


Divinfo. innerhtml = Info;
}
} Now, I created 2 application pools called apppool1 and apppool2; then I created 3 applications called apptest1, apptest2 and apptest3. all of them point to the same directory where my sample is. I put apptest1 under apppool1, apptest2 and apptest2 under apppool2. here is the result: http: // localhost/apptest1/default. aspxcurrent process name: w3wp
Current process ID: 3784
Current application domain:/lm/w3svc/1/root/AppTest1-2-128701111683637820
Current application domain base dir: C: \ Inetpub \ wwwroot \ apptest \ http: // localhost/apptest2/Default. aspxcurrent process name: w3wp
Current process ID: 5044
Current application domain:/lm/w3svc/1/root/AppTest2-1-128701111868733395
Current application domain base dir: C: \ Inetpub \ wwwroot \ apptest \ http: // localhost/apptest3/Default. aspxcurrent process name: w3wp
Current process ID: 5044
Current application domain:/lm/w3svc/1/root/AppTest3-2-128701113026462030
Current application domain base dir: C: \ Inetpub \ wwwroot \ apptest \ here is the conclusion: IIS process is w3wp; every application pool in IIS use it's own process; apppool1 uses process 3784, apppool2 uses process 5044 different applications in Asp.net will use different appdomain; apptest2 and apptest2 are in different appdomain, but in the same process. what's the point to use them? Application pool and appdomain, both of them can provide isolations, but use different approches. application pool use the process to isolate the applications which works. net. but appdomain is another isolation methods provided. net. if your server host thousands of web sites, you wont use thousands of the application pool to isolate the web sites, just becuase, too processing processes running will kill the OS. however, sometime you need application pool. one of the advantages for application pool is that you can config the identity for application pool. also you have more flexible options to recyle the application pool. at least right now, IIS didnt provide explicit options to recyle the appdomain.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.