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

Popular posts from this blog

c# - Unity IoC Lifetime per HttpRequest for UserStore -

Change the color of an oval at click in Java AWT -

I am trying to solve the error message 'incompatible ranks 0 and 1 in assignment' in a fortran 95 program. -