[Remoting] HttpWebRequest/Response isn't remotable?

Discussion in 'C#' started by arcozz, Mar 24, 2009.

  1. arcozz

    arcozz New Member

    Joined:
    Mar 24, 2009
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    Hi i wrote in c# simple app to get HTML code by httpwebreqest/response. Main definition of this method is implemented in serwer exe file. So when I using it by calling this method from client then server application gets from internet this html code. But I want to force client to get this html code from website. I tried to make it Marshal by value but simple Serialization doesn't working. How to do that the object who gets this html code is activated from server but is used local by client?

    thanks a lot

    Code:
    remotable object class libary(interface):
    using System;
    using System.Collections.Generic;
    using System.Text;
    using System.Net;
    using System.IO;
    
    namespace Interfejs
    {
        public interface IPobierz
        {
            string KodHTML(string URL);
        }
    }
    
    definitions for this interface(in serwer)
    using System;
    using System.Collections.Generic;
    using System.Text;
    using System.Net;
    using System.IO;
    using Interfejs;
    
    namespace Serwer
    {
        class Definicje : MarshalByRefObject, IPobierz
        {
            public string KodHTML(string URL)
            {
                HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(URL);
                HttpWebResponse res = req.GetResponse() as HttpWebResponse;
                Stream data = res.GetResponseStream();
                StreamReader sr = new StreamReader(data);
                string html = sr.ReadToEnd();
                return html; 
            }
        }
    }
    
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice