Hostable Web Core (known as HWC) is a new concept in IIS7 to host a website/webservice inside your own process. In short a smaller hosted version of IIS (an IIS7 express edition?). This is accomplished by making a LoadLibrary call to load hwebcore.dll (%systemdrive%\Windows\System32\inetsrv\hwebcore.dll)
From IIS7 onwards you can administer IIS7 remotely using IIS Manager (through HTTPS). When you connect remotely you are actually connecting to a "Web Management Service" called WMSVC. This service uses HWC so that it's not dependent on IIS7 services directly.
Before diving into the code let's see limitations of HWC (Calling it limitation is wrong so let's say it's by design)
- Only one application pool
- Only one website/webservice
- Separate configuration file
- No monitoring like available for IIS7 application pools
- Require IIS7 to be installed
PS: Project files are in VS2008 but the application doesn't have any dependency with newer versions.
Ingredients of my WebCoreService
- Native Windows Service which host HWC which provides install/uninstall options
- Good IIS7 configuration file (applicationHost.config) which contains all configuration required to run ASP/ASPX/ASMX... pages
- TODO: Web/WCF service hosted inside this service which publishes all the management API's for consumption
- TODO: Alternate client for managing IIS7
- Native Windows Service which host HWC. Below is a screenshot to see the options available using command-line
- All the configuration including where the website points to and what port it's hosting the site etc are mentioned in the configuration file called "WebCoreService.config". This is nothing but the actual applicationHost.config file after few of those things removed from it.
- This could be a good managed Webservice or WCF service which would expose management API's.
- How about a Mobile Client? which supports SMS (Texting). Just imagine sending a text message to recycle one of the application pool ?
Hosting management site running inside this?
These are only few of those possibilities though :) think crazy stuff and let me know.
How to RUN the service?
Extract the zip files with source and the binary files.
Follow these steps to setup the service (make sure you are doing this from an elevated command prompt)
- Create a folder called "TestPath" inside your "C:\inetpub\" folder
- Create 2 folder inside called "wwwroot" and "Logs"
- Drop "time.asp" and "time.aspx" pages inside the "wwwroot" folder
- Enable event logs notification from the service
Create a string key "EventMessageFile" and set value as full path to "sample.dll" under the bin folder
Create a DWORD key "TypesSupported" and give value of "00000007"
- Goto the folder where the EXE file resides "WebCoreService.EXE"
- Install the service using the following command
- Start the service using the following command
net start WebCoreService
- Browse to the page http://localhost:8080/time.asp
Bingo! Hostable webcore service is ready.
All the configuration mentioned above like folder path, port number etc can be modified inside the configuration file "WebCoreService.exe.config"
Do let me know if you have any questions or suggestions or even ideas !!!
Source & Binary download @ http://code.msdn.microsoft.com/hwc