Question

using System;
using System.Net;
using System.Xml.Linq;


namespace PhoneApp1
{
    public class ABC
    {
        //constructor

        public ABC()
        {


        }

        void abc()
        {
            String url = "";

            HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
            HttpWebResponse resp = (HttpWebResponse)req.GetRepsonse(); //why a wiggly line here?
            XDocument Xmldoc = XDocument.Load(url);
        }

I do not get GetResponse() for the req object. Why would it be so?

This link and many links says it should be possible.

Was it helpful?

Solution

Given your namespace, I assume you're writing a Windows Phone 7 app. (It would have been helpful to state this explicitly in the question.) Windows Phone 7 development uses Silverlight, which doesn't support synchronous operations like GetResponse. You should be looking at the Silverlight version of MSDN for HttpWebRequest, and looking for members with the phone icon next to them. Note that if you follow that link, you won't find a GetResponse method. You have to call BeginGetResponse and handle it asynchronously.

(This will all become a lot easier with the new async work being put into C# 5.)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top