c# - AuthenticationHeaderValue Vs NetworkCredential -


i'm trying write client either http post or http using httpclient. when googling around come across these methods set these authentication within httpclient object. 1 uses networkcredential while other uses authenticationheadervalue

httpclient sclient; httpclienthandler shandler = new httpclienthandler(); shandler.credentials = new networkcredential("username", "password"); sclient = new httpclient(shandler); 

or

httpclient sclient new httpclient(); sclient.defaultrequestheaders.authorization =    new authenticationheadervalue("basic",convert.tobase64string(system.text.asciiencoding.ascii.getbytes("username:password"))); 

reading on msdn not give me distinct answer differences between them. case both same thing except how authentication information stored? such authenticationheadervalue puts in header while other doesn't? 1 better other in term of use case or best practices ?


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 -