ASP.NET
  Home arrow ASP.NET arrow Page 4 - Understanding .NET Remoting
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
ASP.NET

Understanding .NET Remoting
By: Wrox Team
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 64
    2002-11-25

    Table of Contents:
  • Understanding .NET Remoting
  • Getting Started
  • Hosting the Remote Object on IIS
  • Method 1 (contd.)
  • Hosting the Remote Object in a Managed .NET Application Executable
  • Transport Channels
  • Serialization Formatters
  • Conclusion

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Understanding .NET Remoting - Method 1 (contd.)


    (Page 4 of 8 )

    This is the listing for the ASP.NET page that consumes the Diner Web Service using the code-behind assembly that we just saw in the previous section:

    <%@ Page language="C#" Codebehind="PizzaRemotingClientHTTP" & _
    inherits="PizzaRemotingClientHTTP.RemoteClient" %>

    .........

    <asp:DataList runat="server" id="PizzaList"
    RepeatColumns="2" RepeatDirection="Vertical" RepeatMode="Table" DataSource='<%# PizzaMenu %>'
    Width="100%">
    <property name="AlternatingItemStyle">
    <asp:TableItemStyle BackColor="#f5deb3"/>
    </property>
    <template name="ItemTemplate">
    <asp:Panel runat=server font-size="12pt" font-bold="true">
    <%# DataBinder.Eval(Container.DataItem, "Name") %>
    </asp:Panel>
    <asp:Label runat=server font-Size="8pt"
    Text='<%# DataBinder.Eval(Container.DataItem, "Description") %>'>
    </asp:Label>
    <asp:Label runat=server font-Size="10pt" Text="$" ForeColor="Blue">
    </asp:Label>
    <asp:Label runat=server font-Size="10pt" ForeColor="Blue"
    Text='<%# DataBinder.Eval(Container.DataItem, "Cost") %>' >
    </asp:Label>
    </template>
    </asp:DataList>


    Method 2: (Using a configuration file on the client to register the channel and specify the object's URN)
    Creating and registering the channel explicitly and then using Acivator.GetObject is just one way of invoking the remote object. You can also specify the channel and the URI endpoint of the remote object through a configuration file , and just instantiate the Diner object using new . The client application will use the information in the loaded configuration file to register the channel and activate the object at the URI endpoint specified.

    The general format of the client configuration file is as follows:

    Name#Name of the Application
    Assembly#[AssemblyName]#[RemoteApplicationName]
                          
    #[FullTypeName]=[ObjectURI]
    RemoteApplication#[RemoteApplicationName]
                           #[RemoteApplicationURI]
    Channel#[ChannelAssemblyName]#[ChannelFullTypeName]#[Name=Value;Name=Value]


    So based on the above format, here's how your configuration file ( MyDinerClient.cfg ) would look like:

    Name#MyDinerClientConfig
    Assembly#MyDiner#MyDiner#MyDiner.Diner=
                            HTTP://bingo:80/MyDiner/Diner.soap
    RemoteApplication#MyDiner#HTTP://bingo:80/MyDiner
    Channel#System.Runtime.Remoting
                   #System.Runtime.Remoting.Channels.TCP.TCPChannel
    Channel#System.Runtime.Remoting
                  #System.Runtime.Remoting.Channels.HTTP.HTTPChannel


    To load this configuration file, we have to use the RemotingServices.ConfigureRemoting method and pass it the name of the client configuration file to use. The information in the configuration file is used to register the channel and use the specified remote URI endpoint to activate the object. You must load the configuration file only once, typically when your application starts up. Shown below is the global.asax file for an ASP.NET consumer application that loads the configuration file.

    <%@ Import Namespace="System.Runtime.Remoting" %>
    <script runat="server" language="vb">
    Sub Application_OnStart()
    RemotingServices.ConfigureRemoting(HttpContext.Current.
    Server.MapPath("MyDinerClient.cfg"))
    End Sub
    </script>


    So now, since we have all the details specified in the configuration file, we do not have to explicitly register the channel or provide details about the object's URN endpoint in our code. You would simply have to create the object using new and then call its methods as shown below:

    // Create an instance of the remote object
    Diner dinerObj = new Diner();

    // Get Today's Menu from the remote Pizza Service
    if(dinerObj != null)
    m_listPizza = dinerObj.getPizzaMenu();


    If there's an inkling of doubt whether your ASP.NET page is accessing the locally deployed assembly instead of the remote one, simply shut down the remote server or rename the assembly on the remote server and you will see that the client will choke.

    More ASP.NET Articles
    More By Wrox Team


       · Very good article. Congratulations It is old but helped me a lot. In my case my...
     

    ASP.NET ARTICLES

    - How Caching Means More Ca-ching, Part 2
    - How Caching Means More Ca-ching, Part 1
    - Reading a Delimited File Using ASP.Net and V...
    - What is .Net and Where is ASP.NET?
    - An Object Driven Interface with .Net
    - Create Your Own Guestbook In ASP.NET
    - HTTP File Download Without User Interaction ...
    - Dynamically Using Methods in ASP.NET
    - Changing the Page Size Interactively in a Da...
    - XML Serialization in ASP.NET
    - Using Objects in ASP.NET: Part 1/2
    - IE Web Controls in VB.NET
    - Class Frameworks in VB .NET
    - Cryptographic Objects in C#: Part 1
    - Sample Chapter: Pure ASP.Net







    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 5 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek