Link to home
Start Free TrialLog in
Avatar of Russ Suter
Russ Suter

asked on

How do I relay an HTTPWebResponse?

        protected void Page_Load(object sender, EventArgs e)
        {
            HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://www.url.com/test");

            string postData = this.Request.Form.ToString();
            byte[] data = Encoding.UTF8.GetBytes(postData);

            request.Method = "POST";
            request.ContentType = this.Request.ContentType;
            request.ContentLength = data.Length;
            request.UserAgent = this.Request.UserAgent;

            using (Stream stream = request.GetRequestStream())
            {
                stream.Write(data, 0, data.Length);
            }

            // ??? How do I do this...
            // this.Response = request.GetResponse();
        }

Open in new window

I'm just missing that last part. The code that is commented doesn't compile because I can't set this.Response to anything but that's essentially what I'm trying to do.
Avatar of louisfr
louisfr

You cannot set the Response property. Set the Response's properties instead.
ASKER CERTIFIED SOLUTION
Avatar of Russ Suter
Russ Suter

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Russ Suter

ASKER

Found the solution elsewhere. Posting what I found here.