INFO: Configure .NET Remoting When the Remoting Client Is an ASP.NET Application or the Client Is Another Remoted Component That Is Hosted by IIS

Article translations Article translations
Article ID: 323490 - View products that this article applies to.
This article was previously published under Q323490
This article has been archived. It is offered "as is" and will no longer be updated.
Expand all | Collapse all

On This Page

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).

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.

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
				

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>
				

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.

REFERENCES

For more information visit the following Microsoft Web sites:
Hosting Remote Objects in Internet Information Services (IIS)
(http://msdn.microsoft.com/library/default.asp?url=/library/en-us/ cpguide/html/cpconhostingremoteobjectsininternetinformationservicesiis.asp)
Remote Object Configuration
(http://msdn.microsoft.com/library/default.asp?url=/library/en-us/ cpguide/html/cpconremoteobjectschannels.asp)
Format for .NET Remoting Configuration Files
(http://msdn.microsoft.com/library/default.asp?url=/library/en-us/ dndotnet/html/remotingconfig.asp)
For additional information, click the article number below to view the article in the Microsoft Knowledge Base:
303247 INFO: ASP.NET Code-Behind Model Overview

Properties

Article ID: 323490 - Last Review: February 27, 2014 - Revision: 4.4
APPLIES TO
  • Microsoft ASP.NET 1.0
  • Microsoft ASP.NET 1.1
  • Microsoft .NET Framework 1.0
  • Microsoft .NET Framework 1.1
  • Microsoft Internet Information Services 5.0
  • Microsoft Internet Information Services 6.0
  • Microsoft Internet Information Services version 5.1
Keywords: 
kbnosurvey kbarchive kbconfig kbhowtomaster kbinfo kbremoting KB323490

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com