The remote server returned an error: (406) Not Acceptable

This error occurs very infrequently in Web browsers, because most browsers will accept any data returned from the Web server.
If the client is not a Web browser, then anyone can only investigate the problem by looking at the Accept headers generated by the client system and the data stream returned by the Web server.

Using WebClient:

WebClient Client = new WebClient();
client.Headers.Add("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8");

Using HttpWebRequest:

HttpWebRequest request = WebRequest.Create("http://where.yahooapis.com/v1/place/1/children?appid=[miAppId]") as HttpWebRequest;
request.Accept="text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8";
Annunci

Informazioni su Andrea Regoli

Project Manager .Net Developer WPF WP7 Asp.Net c# javascript ajax SQL sharepoint
Questa voce è stata pubblicata in c# e contrassegnata con , , , . Contrassegna il permalink.

2 risposte a The remote server returned an error: (406) Not Acceptable

  1. Bhumika ha detto:

    thanks you saved lot of time.appriciated

  2. Asim Shazhad ha detto:

    Thanks. This really works. Thumbs Up 🙂

Rispondi

Inserisci i tuoi dati qui sotto o clicca su un'icona per effettuare l'accesso:

Logo WordPress.com

Stai commentando usando il tuo account WordPress.com. Chiudi sessione / Modifica )

Foto Twitter

Stai commentando usando il tuo account Twitter. Chiudi sessione / Modifica )

Foto di Facebook

Stai commentando usando il tuo account Facebook. Chiudi sessione / Modifica )

Google+ photo

Stai commentando usando il tuo account Google+. Chiudi sessione / Modifica )

Connessione a %s...