In the yesterday post (.NET Remoting binary config) I’ve showed how to host an object in a windows application, this post will show the IIS hosting config. To make this really easy create in VS.NET a new web site project named AlephServer and add a reference to the AlephServerCore.dll. Next add a web.config to the project with this content:
<?xml version=”1.0″ encoding=”utf-8″ ?>
<configuration>
<system.runtime.remoting>
<application>
<service>
<wellknown mode=”Singleton” type=”AlephServerCore.Service, AlephServerCore” objectUri=”AlephServer.rem” />
</service>
<channels>
<channel ref=”http”>
<serverProviders>
<formatter ref=”binary” typeFilterLevel=”Full” />
</serverProviders>
</channels>
</application>
</system.runtime.remoting>
</configuration>
The client code will not change at all, just the config file. The URL will no longer be ”http://localhost:8080/AlephServer” but ”http://localhost/AlephServer.rem” because the IIS will use the default 80 port.
PS: There is a difference between the windows app hosting and the IIS and that is an ASP.NET bug, when the server will timeout the BinaryFormatter will try to interpret the HTML text as a binary input. To fix this you’ll have to use a custom Channel Sink made by Richard Blewett. The project and can be downloaded from his blog.