Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C# (http://www.go4expert.com/forums/c-sharp/)
-   -   [Remoting] HttpWebRequest/Response isn't remotable? (http://www.go4expert.com/forums/remoting-httpwebrequest-response-isnt-t16652/)

arcozz 25Mar2009 00:48

[Remoting] HttpWebRequest/Response isn't remotable?
 
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;
        }
    }
}



All times are GMT +5.5. The time now is 10:22.