I am creating a chat application and I am using a free webhosting to store the online users in a database. I have the following structure:
1) index.php
where i get the online users in this format:
<user> <name></name> <ip></ip> </user>
2) add.php?user=
to add a new user to the database when he connects.
3) remove.php?user=
to remove a user when he disconnects.
Now in the application I have a function GetUsers()
like this:
string url = @"http://.../index.php";
System.Net.WebRequest req = System.Net.WebRequest.Create(url);
System.Net.WebResponse res = (System.Net.WebResponse)req.GetResponse();
If I am using the local IIS server for the url it works but when I try with the free webhosted url it gives me an 406 Not Acceptable
error. So I think I need to put some headers or something to fake a real browser.
UPDATE: 1) The free hosting service is using Apache as the webserver. 2) You can suggest another approach to fetch the web page.