This article has been excerpted from book "The Complete Visual C# Programmer's Guide" from the Authors of C# Corner.

It is also possible for Internet Information Server (IIS) to host remote objects. The Web-hosting example is in the Sample1 folder. The console client project is named WebClientExe.

To use IIS as a server, you must take a number of steps:

Listing 25.26: Web.config

<?
xml version="1.0" ?>
<
configuration>
<
system.runtime.remoting>
<
application>
<
service>
<
wellknown
mode="SingleCall"
type="SimpleObjectLib.SimpleObject, SimpleObjectLib"
objectUri="Simple.rem">
</
wellknown>
</
service>
<
channels>
<
channel
name="Server-Activated Web Client"
type="System.Runtime.Remoting.Channels.Http.HttpChannel, System.Runtime.Remoting"/>
</
channels>
</
application>
</
system.runtime.remoting>
</
configuration>

You should be aware of a number of items in the configuration file:

Listing 25.27: WebClient.cs

ChannelServices.RegisterChannel(new HttpChannel());
SimpleObject simple = null;
simple = (SimpleObject)Activator.GetObject( typeof(SimpleObject), "http://localhost/WebRemoting/Simple.rem");
string
ret = null;
ret = simple.ConCatString( "using the", "Web for remoting.");

Figure 25.16: WebClientExe Output

Conclusion

Hope this article would have helped you in understanding Remoting over the Web. See other articles on the website on .NET and C#.

visual C-sharp.jpg The Complete Visual C# Programmer's Guide covers most of the major components that make up C# and the .net environment. The book is geared toward the intermediate programmer, but contains enough material to satisfy the advanced developer.