开发者

IIS AppDomain instantiation

I have a web site and a web service under the same virtual directory and some of the web pages call the web service.

When the web service is called, does开发者_运维技巧 IIS create a new AppDomain or does it run the web service in the same AppDomain?

Is there a setting for this? On one of my machine it appears to create a new AppDomain. Does changing application pool mode from Integrated vs Classic affect this?


IIS Application Pools run a single worker process (by default). Within that worker process, an AppDomain is created for each IIS Application (website). As far as I am aware, any code executing within that IIS Application will run in the same AppDomain (unless of course you are creating your own child application domains in code yourself). You can adjust the number of worker processes per website, but realistically only do this if you are finding you are having performance issues (that cannot be resolved by segregating the application pools). If you run multiple application domains per website, code running in those separate application domains cannot share state (e.g. InProc session), and can only communicate through serialisation - not ideal.

In regards to ASP.NET and WCF; when hosted in IIS they by default run in side-by-side mode, within the same AppDomain, this allows them to share state, but WCF requests are not processed by the ASP.NET runtime, instead calls to WCF services are intercepted and processed by the WCF runtime. (Although calls to .svc files are still routed through ASP.NET initially). In side-by-side mode, WCF calls do not obey configuration, security, impersonation etc. that you may have configured for your ASP.NET website.

WCF on IIS can also be run in ASP.NET Compatibility mode, in which the WCF implementation is managed by a http handler, and thus are processed by the ASP.NET pipeline also. If you would consider that your services need only HTTP support, you could consider hosting the service in compatability mode to gain access to the power and flexibility of the ASP.NET pipeline.

In regards to Integrated and Classic pipeline mode, in Intergrated mode, ASP.NET is run by the w3wp.exe as an integrated part of the IIS processing pipeline. This means that anything using custom handlers, etc, that you may have plugged into the pipeline (even when serving non-ASP.NET content, e.g. PHP), will be loaded and executed in the same AppDomain.

In Classic mode, ASP.NET is run in its owner worker process, aspnet_wp.exe, and is connected to the IIS processing pipeline as an ISAPI filter. I believe the same mechanics around AppDomain usage applies here also.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜