Conception Overview:
It is a better option to host a WCF service within Internet Information Services Server
(IIS) because IIS provides a robust, efficient, and secure host for the WCF services.
IIS also has better thread and process execution boundaries handling (in addition
to many other features) compared to a regular managed application.
The main drawback of hosting the service within IIS prior to version 7.0 is the tight
coupling between ASP.NET and web services, which limits the transport protocol
to HTTP/HTTPs. But with IIS 7.0, in addition to HTTP, you can now host a WCF
service with TCP, Named pipe, or MSMQ. You are no longer limited to HTTP.
Another thing you need to pay particular attention to when hosting WCF in IIS is
that the process and/or application domain may be recycled if certain conditions
are met. By default the WCF service session state is saved in memory so that
each recycle will lose all such information. This will be a big problem if you run a
website in a load-balanced or web-farm (web-garden) environment. In this case,
you might want to turn on the ASP.NET compatibility mode (add the attribute,
AspNetCompatibilityRequirements, to your WCF service) so that the session
state can be persisted in a SQL Server database or in the ASP.NET State Server.