Situation:
I have website which calls WCF Service and i'm trying to understand it..
Question:
Consider i have a ASP.Net (IIS7 hosted) website how do i relate AppDomain, W3Wp.exe Process , Instance ,App.Pool.& How can i relate WCF service with (AppDomain, Instance ,App.Pool) with WAS server & Windows Service..when multiple requests are made to asp.net website & website calls WCF ..how it will be related with each other? i'am little confused...
If possible can anyone of you put a diagram to relate it..
Highly appreciate your responses
What exactly is it you need to know or doesn't understand?
W3Wp.exe is the process IIS uses to run a AppPool in
AppPool is a IIS concept, doesn't exist in .Net
Each website application runs in it own AppDomain
AppPools is run multiple website applications inside the same process
AppDomain is a .Net concept that relates to how code executes inside your application, establishes boundaries and such.
From MSDN: Represents an application domain, which is an isolated environment where applications execute.
You can have many AppDomains inside the same process, but AppDomains cannot live across different processes.
Code in one AppDomain can create new AppDomains
You can communicate across AppDomain boundaries via Remoting
Technique for communicating with another AppDomain in the same process, in another process or even on a remote computer is the same.
All code in .Net has to be executed inside a AppDomain. If you're hosting your WCF service in your ASP.Net application the WCF service will run in the same AppDomain as your ASP.Net application (see WCF and ASP.Net http://msdn.microsoft.com/en-us/library/aa702682.aspx). In that context the AppDomain will be running in a AppPool inside IIS, but that hos nothing to do with .Net.
If you're hosting the WCF service in a Windows Service the WCF service will run inside the AppDomain created by the Windows Service, no AppPools involved here.
If your execution path is
Client requests asp.net webpage hosted on IIS
webpage requests WCF service hosted in a Windows Service
then there will be 1 AppPool, 1 W3Wp.exe process, 1 Windows Service process and 2 AppDomains involved.
I don't know if your question relates in any way to WCF service Appdomain details ?
Related
I want to try moving to VNext from Asp.Net MVC 3, I used windows service project (http://www.interworks.com/blogs/banderton/2009/10/30/long-running-tasks-aspnet) but this doesn't seem to work on VNext, because it doesn't have proper System.ServiceModel reference and I cant add dll.
Is there a way around? Would you recommend other ways to run long tasks such as big file import/calculations with VNext?
Generally, no - not because of any feature-set in ASP.NET vNext (it's been possible since .NET 1.0) but because of permissions: a process needs to run under a high-privilege security context or be able to impersonate such a user account in order to control Windows Services.
w3wp.exe (the application pool hosting process, and by extension, the application pool and the applications within it) all typically run under a least-privilege user-account (often NT AUTHORITY\NETWORK SERVICE or a custom user account with enough permissions to write to the website's root directory, a database server, and not much else (in recent versions of Windows this is further reduced to the concept of a "service account" which your worker-process and pools run under).
The easiest solution is to create a user-account with the necessary privileges to control services and run your application pool process under this user-account, but I don't recommend this.
Consider, instead, creating a new Windows Service that then controls the other service (or if it's your own service, do it in-proc) that uses some form of IPC to communicate with your ASP.NET application to shut itself down and perform other tasks. You might want to look at named-pipes, for example.
If you need to run ASP.NET in a Windows service, you can do it now using ASP.NET 5. I wrote a detailed post on how to do this here: http://taskmatics.com/blog/host-asp-net-in-a-windows-service/
I have a Windows 2008 R2 IIS7 web server with a .Net 3.5 web application which communicates with a .Net 3.5 web service on the same machine over https. Occasionally (maybe once in two days) the web application receives an error "remote name could not be resolved '[machinename]'" when calling the web service. The web server is set up to recycle the application pool every night, the error occurs during normal business hours. I could not detect anything unusual in the logs, the worker process does not consume a lot of memory either.
Any ideas?
Note: The web application and the web service were originally on two different machines. I moved the web service to the web application's server when trying to identify the cause of the problem.
I'm building a windows service but I would like to get some web pages to control some settings, get diagnostics, etc...
How would you go about combining an asp.net web site AND a windows service together ?
I know that WCF can be self hosted into an arbitrary process but can I do the same with asp.net ?
Another option would be to have my service logic in the asp.net web site application_start method to spawn long running threads. But then, I don't get window service built in feature such as auto start on boot up. Another issue might be that IIS might decide to recycle the process. Moreover, my service needs to open a raw tcp socket to accept connections. Can I do that in IIS ?
Thanks
I think the easiest and most robust way to do this is to have an ASP.NET Web Site running under IIS on the same server as the Windows Service. The Windows Service can host a WCF Web Service that will be accessible to the ASP.NET application.
I would have your Windows service self-host a WCF "configuration" service. The WCF service only needs to be exposed locally if the UI is on the same machine. If the windows service needs to open a separate raw socket for communications this can punch a hole through the firewall.
Then the ASP.NET UI can be hosted by IIS as usual, and call the WCF methods to perform the configuration tasks.
It seems like you really need both things—a web app hosted in IIS and a windows service hosted as windows service.
Then you can just share data between the two in some way, e.g. via a database.
What is difference between application domain and application pool?
I have read many articles regarding these two terminology. but still unable to get proper understanding about them.
Please elaborate it with simple description.
Thanks
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;
AppTest1 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 approaches. Application pool
use the process to isolate the applications which works
without .NET. But AppDomain is another isolation methods
provided by .NET.
If your server host thousands of web sites, you wont use
thousands of the application pool to isolate the web sites,
just because, too many 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 recycle the application pool. At least right now,
IIS didn't provide explicit options to recycle the appdomain.
An application pool is a group of one or more URLs of
different Web applications and Web sites. Any Web directory
or virtual directory can be assigned to an application pool.
Every application within an application pool shares the same
worker process executable, W3wp.exe, the worker process that
services one application pool is separated from the worker
process that services another [Like starting MS Word and
opening many word documents]. Each separate worker process
provides a process boundary so that when an application is
assigned to one application pool, problems in other
application pools do not affect the application. This
ensures that if a worker process fails, it does not affect
the applications running in other application pools. [i.e]
for Eg., If word document is having issue it should not
logically affect your Excel Sheet isn’t it.
application domain is a mechanism (similar to a process in
an operating system) used to isolate executed software
applications from one another so that they do not affect
each other. [i.e] opening of MS WORD doesn’t affect MS EXCEL
you can open and close both the applications any time since
there is no dependency between the applications. Each
application domain has its own virtual address space which
scopes the resources for the application domain using that
address space.
Thanks to this link
Edit 1
I am confused with the statement below, taken from What ASP.NET Programmers Should Know About Application Domains :
You’ve created two ASP.NET
applications on the same server, and
have not done any special
configuration. What is happening?
A single ASP.NET worker process will
host both of the ASP.NET applications.
On Windows XP and Windows 2000 this
process is named aspnet_wp.exe, and
the process runs under the security
context of the local ASPNET account.
On Windows 2003 the worker process has
the name w3wp.exe and runs under the
NETWORK SERVICE account by default.
He said that there is one worker process spawns 2 application domains--one application domain for each asp.net application.
But when I see the running processes as follows,
Image 1
Image 2
w3wp.exe is said as IIS Worker Process rather than application pool or application domain.
Questions:
Is application domain equal to application pool?
The confusing thing is in image 1. Why does Host Process Windows Service svchost.exe spawns 2 IIS Worker Process w3wp.exe? In my understanding, a process can only contain application domains, not other processes.
Application domain aka AppDomain (its class representation) is an encapsulated environment inside a .NET runtime where assemblies are loaded and running.
Usually there is one AppDomain/Application domain per managed process but can be more. Here the article refers to 2 AppDomains inside the same w3wp3.exe process.
You can see number of AppDomains loaded in any process using perfmon.exe
To answer your question, usually one AppDomain is created per one AppPool. But it is possible to load extra AppDomains manually in the AppPool by the application - but that would be very uncommon.
Update
I think you are using Process Explorer of the Sysinternals. Ignore the way it shows the tree structure in there, it only illustrates which process has spawned other processes. In fact it shows most processes underneath explorer since explorer has been used to load it.
Also SVCHOST.exe is an unmanaged executable and although it can host CLR and load AppDomains, it normally does not do that.