c# - NTLM authentication not working when using Windows.Web.HttpClient having AllowUI set false -


i porting windows 8.1 app windows 10 uwp app. problem have encountered old code (it still compiling though) uses system.net.httpclient throws stupid exception when trying authenticate on server using ntlm.

"known windows 10 sdk error - fixing it." - microsoft since months. (described else here: https://social.msdn.microsoft.com/forums/en-us/9e137127-e0e5-4aec-a7a9-d66f5b84c70b/rtm-known-issue-systemnethttphttpclient-or-httpwebrequest-class-usage-in-a-uwp-app-throws-a?forum=win10sdktoolsissues)

the workaround? - "use windows.web.httpclient instead"

so trying.

var request = new httprequestmessage();  request.requesturi = myuri; request.method = httpmethod.post; request.content = new httpstringcontent(mycontent);  request.headers.add("user-agent", "myapp"); request.headers.add("soapaction", "mysoapaction"); request.content.headers.contenttype = new httpmediatypeheadervalue("text/xml; charset=utf-8");  var filter = new httpbaseprotocolfilter(); filter.allowautoredirect = true; filter.allowui = true;   filter.servercredential = new passwordcredential(address, username, password);  httpclient client = new httpclient(filter);          var response = await client.sendrequestasync(httpmessage);  

and works! displays ugly system popup on app asking enter credentials (it filled in - because have set credentials in code) - after hitting ok button response status ok - worked harm, way should.

so problem? problem when don't want show system popup users. if set:

filter.allowui = false; 

all magic disappears. no popup, no authentication. response gives 401 error. unauthorized.

why? doing wrong? possible have ntlm authentication working fine on windows 10 uwp apps without system popup? sdk issue?

i have solution implemented , work ntlm. have "enterprise authentication" , "internet (client & server)" capabilities checked , provide domain username?


Comments

Popular posts from this blog

ruby - Trying to change last to "x"s to 23 -

jquery - Clone last and append item to closest class -

c - Unrecognised emulation mode: elf_i386 on MinGW32 -