Tuesday, June 17, 2014

Ajax post method using HttpWebRequest for pocket pc .net 3.5

This login method for get the value from the webserver using ajax post.

The pocket pc didn't support the WebClient and HttpWebClient only support WebRequest.

HttpWebRequest is registered automatically. You do not need to call the RegisterPrefix method to register System.Net.HttpWebRequest before using URIs beginning with http:// or https://.

 here is the sample code for HttpWebRequest using ajax post.

HttpWebRequest myReq =
(HttpWebRequest)WebRequest.Create("http://www.contoso.com/");

Sample method source code:


string brandEndPoint = base_url+"?email=" + username + "&password=" + password;
HttpWebRequest request = WebRequest.Create(brandEndPoint) as HttpWebRequest;
request.Method = "GET";
request.ContentType = "application/text";
request.ContentLength = 0;
request.Expect = "application/xml";

HttpWebResponse response = request.GetResponse() as HttpWebResponse;
if (response.StatusCode.ToString().ToLower() == "ok")
{
//do some thing
}

No comments:

Post a Comment