SUMMARY
This article describes configuration information for .NET remoting when the remoting client is an ASP.NET application or the client is another remoted component hosted by Internet Information Services (IIS).
back to the top
Configure Remoting Client in Global.asax
When you use a remote .NET component from an ASP.NET page, or from another IIS-hosted component, you must establish the remoting configuration on application startup. You cannot set a client configuration (that works) in the Web.config file in this scenario. Instead, use the
Application_Start event in Global.asax for the application to peform any remoting configuration.
IMPORTANT NOTE: The client configuration file can be
any file, including Web.config. By default,
client elements of Web.config are not read. To work around this behavior, in this example you must configure the client remoting configuration by using the
Application_Start method.
By default,
service elements in Web.config
are read, however. For clarity, this example uses a separate configuration file for the client. You may include your client configuration in the Web.config file, but you still must call
Configure in
Application_Start.
back to the top
Use Application_Start to Configure Remoting Client
The following sample code is an example of the code that you add to the
Application_Start method in the Global.asax to perform client remoting configuration:
Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)
Dim sPath = Server.MapPath("ClientConfiguration.config")
System.Runtime.Remoting.RemotingConfiguration.Configure(sPath)
End Sub
back to the top
Remoting Client Configuration File
The following sample code is an example of the configuration code that you can use in the configuration file. This sample code demonstrates how to use a well-known endpoint, the http channel, and the binary formatter.
<configuration>
<system.runtime.remoting>
<application>
<client>
<wellknown
url="http://servername/remote/class1.rem"
type="RemoteObject.Class1, RemoteObject"
/>
</client>
<channels>
<channel ref="http" useDefaultCredentials="true" >
<clientProviders>
<formatter ref="binary"/>
</clientProviders>
</channel>
</channels>
</application>
</system.runtime.remoting>
</configuration>
back to the top
Remote Components Hosted by IIS
Use this method to set the remoting configuration when a remote component that is hosted by IIS is the client of another remote component. In this scenario, add a Global.asax file to the same virtual directory where the IIS-hosted remote component is located. Add configuration code to the
Application_Start method as shown previously.
back to the top