Consuming a live REST services in ASP.NET -


can point me , working examples of how consume restful services in web asp.net. tutorials, walk-through or useful material. join company require me , new asp.net rest service. have used many materials , yet not clear.

help me b c of rest usage in asp.net pls

here code works rest servive. using system; using system.collections.generic; using system.linq; using system.net.http; using system.net.http.headers; using system.web; using system.web.ui; using system.web.ui.webcontrols; using system.web.script.serialization; using newtonsoft.json; using system.io; using system.runtime.serialization.formatters; using system.net;   namespace webtestrestfullservice {     public partial class _default : page     {         public string js;         public string resp;         protected void page_load(object sender, eventargs e)         {          }          public void page_init(object sender, eventargs e)         {             using (var client = new httpclient())             {                 //client.baseaddress = new uri("http://88.208.232.99:0000");//dont use this.                 client.defaultrequestheaders.accept.clear();                 client.defaultrequestheaders.accept.add(new mediatypewithqualityheadervalue("application/json"));                 //this wrong                 //client.defaultrequestheaders.accept.add(new mediatypewithqualityheadervalue("correct/api/"));                 string query = "correct/api/";//you must api refernce correct.                 // http                 //httpresponsemessage response = await client.getasync(". ");                 string resp = "";                  var task = client.getasync(query).continuewith                     ((taskwithresponse) =>                         {                             var response = taskwithresponse.result;                             var jsonstr = response.content.readasstringasync();                             jsonstr.wait();                             resp = jsonstr.result;                         });                 task.wait();                     response.write(resp);                 // string data =  $.parsejson(lbltest.text);                 // session["resp"] = resp;                 // new code              }         }      } } 

Comments

Popular posts from this blog

magento2 - Magento 2 admin grid add filter to collection -

Android volley - avoid multiple requests of the same kind to the server? -

Combining PHP Registration and Login into one class with multiple functions in one PHP file -