Some background.
Currently have an asp.net web site which is contained on 2 web servers which are load balanced i.e. web farm.
I would like to have some code which would allow me to call a particular server and execute a method on it. I WANT TO do this so that i can force all web servers to refresh their cache via a web page on the site.
Use Case is: Admin user logs into site and makes a change to a setting which is cached and then clicks “Refresh web server cache” button which then calls the update cache method on each of the servers. this is to prevent me from having to restart the app pool every time a cached setting is changed.
Jamiec’s answer is correct; each machine still has its own IP. I use an ASHX handler to receive the requests to reset the cache. Any machine in the web farm can initiate the request.
This is a fairly complete example, but there are some helper methods and configuration settings that I have not included.
Here’s the code to actually invoke a handler on each site that performs the cache reset. I suggest using some sort of shared password between machines and separately securing the handler so that it can’t be accessed publicly.
Handler code itself (sorry for length).