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 (323490)



The information in this article applies to:

  • Microsoft ASP.NET (included with the .NET Framework) 1.0
  • Microsoft ASP.NET (included with the .NET Framework 1.1)
  • Microsoft .NET Framework 1.0
  • Microsoft .NET Framework 1.1
  • Microsoft Internet Information Services 5.0
  • Microsoft Internet Information Services version 6.0
  • Microsoft Internet Information Services version 5.1

This article was previously published under Q323490

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

REFERENCES

For more information visit the following Microsoft Web sites: 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

back to the top

Modification Type:MajorLast Reviewed:6/28/2004
Keywords:kbConfig kbHOWTOmaster kbinfo kbRemoting KB323490 kbAudDeveloper