Why does the System.Net.HttpWebRequest not have Host property?

IvanHarrisIvanHarris ✭✭✭USMember ✭✭✭
edited March 2013 in Xamarin.Android

Why does HttpWebRequest have everything EXCEPT the Host property?

Error I am getting:

Error 2 'System.Net.HttpWebRequest' does not contain a definition for 'Host' and no extension method 'Host' accepting a first argument of type 'System.Net.HttpWebRequest' could be found (are you missing a using directive or an assembly reference?)

I need the Host property. Anyone know how I can add the Host property to the HttpWebRequest class or any way around it?

Can I just add this?:

string host = "http://www.somewebsite.com";
http.Headers.Add("Host", host);

Posts

  • MatthijsMatthijs USMember, Beta

    According to MSDN it should be there, but looking into the Xamarin implementation it appears to be missing indeed.
    So looking at what the property should do, I suppose you could indeed use the alternative as you suggested.

  • JonathanPryorJonathanPryor Xamurai USXamarin Team Xamurai

    Why does HttpWebRequest have everything EXCEPT the Host property?

    Because the original incarnation of HttpWebRequest was based on the Silverlight API, which lacks the Host property.

    The newer Xamarin.Android 4.7.x alphas track closer to .NET 4.5 and does contain the HttpWebRequest.Host property.

Sign In or Register to comment.