c# - How to execute an URL with Windows Phone? -
i need execute url button in wp app:
i tried code doesn't work more once:
private void btnledon_click(object sender, routedeventargs e) { var request = httpwebrequest.create(new uri("http://192.168.0.1/?ledon")); request.begingetresponse(new asynccallback(ongettingresponse), request); } private void ongettingresponse(iasyncresult ar) { var req = ar.asyncstate httpwebrequest; var response = (httpwebresponse)req.endgetresponse(ar); var responsestream = response.getresponsestream(); }
i don't need response just url executed led turn on/off. easier way or reset request work more once?
you should use httpclient
(check link).
it's modern approach http of modern .net framework , works better rest-style requests since you'll find direct shortcuts perform get, post, put, delete, head , other verbs' resource requests.
Comments
Post a Comment