c# - Universal App NTLM working for Windows Store, but not Windows Phone -


i building universal app accesses web api data.

when run authentication piece in windows store app, works , 200 response on login call (an http post call _url2 in code below)

when run exact same code windows phone emulator, 401 unauthorized.

here code i'm using access service:

var handler = new httpclienthandler {     allowautoredirect = true,     preauthenticate = true,     cookiecontainer = _cookies,     credentials = new networkcredential(username, password),     usecookies = true,     automaticdecompression = decompressionmethods.gzip | decompressionmethods.deflate }; using (var client = new httpclient(handler, true)) {     //client.defaultrequestheaders.connection.add("keep-alive");     //  having connection = keep-alive causes phone throw exception... not needed, annoying     client.defaultrequestheaders.accept.add(new system.net.http.headers.mediatypewithqualityheadervalue("*/*"));      var res = await client.getasync(_url1);  // works , negotiate ntlm on both platforms.  returns 200 on both phone , store apps       client.defaultrequestheaders.add("x-requested-with", "xmlhttprequest");     client.defaultrequestheaders.referrer = new uri(_url1);     client.defaultrequestheaders.add("origin", _url1);      using (var message = new httprequestmessage(httpmethod.head, _url2))     {         var header = await client.sendasync(message);  // 401 on phone, 200 on store app     }      var resp = await client.postasync(_url2, new stringcontent(logincontent));   // 401 on phone, 200 on store app      using (var stream = await resp.content.readasstreamasync())     using (var reader = new streamreader(stream))     {         var html = await reader.readtoendasync();          parseloginresults(html);     } } 

i think when client other get, seems not complete ntlm handshake... haven't been able configure fiddler work emulator, haven't gotten trace on going on. communication on https can't useful on wireshark either.

any idea why works on windows store apps, not on phone? there other work arounds ntlm authentication? can manually?

it´s far completed try : http://uwapi.codeplex.com/

however...as far know windows phone emulator not allow https connections localhost. maybe that´s problem. need add certificate allow https traffic.


Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -