http - httpclient postasync windows phone 8.1 universal app second call 404 error -
i have problem httpclient in universal windows phone 8.1 app. i've been looking have not valid solution in post.
the problem that, when call web service first time runs correctly, when call it, second or third time, gives me error 404.
until restart application not run again.
i need send data in post function cause want send xml formated string.
my code simple:
var handler = new httpclienthandler { credentials = new networkcredential("user", "pass", "domain") }; using (var client = new httpclient(handler)) { var formcontent = new formurlencodedcontent(new[] { new keyvaluepair<string, string>("xmltext", xmltext), new keyvaluepair<string, string>("param1", "textparam1") }); httpresponsemessage response = new httpresponsemessage(); response = await client.postasync(url, formcontent); var responsestring = response.content.readasstringasync().result; messagedialog msgbox = new messagedialog(responsestring); await msgbox.showasync(); }
and web service simpler:
[webmethod] public string setenvioxml(string xmltext, string param1) { return xmltext; }
any solution?
sorry english , thaks all!
any welcome!
try use below code may works, first try run on google rest client or post man
httprequestmessage httprequest = new httprequestmessage(); httprequest.method = httpmethod.post; httprequest.requesturi = url; httprequest.content = formcontent ; response =await client.sendasync(httprequest);
Comments
Post a Comment