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
Post a Comment