how to pass username password from C# client to web api. when do get

evil nemesis

New Member
for example I have a webapi : http://sampleweb.com/api/product.I have a C# client to consume this webapi.something like that to get whole list of product.\[code\]// List all products.HttpResponseMessage response = client.GetAsync("api/products").Result; // Blocking call!if (response.IsSuccessStatusCode){ // Parse the response body. Blocking! var products = response.Content.ReadAsAsync<IEnumerable<Product>>().Result; foreach (var p in products) { Console.WriteLine("{0}\t{1};\t{2}", p.Name, p.Price, p.Category); }}else{ Console.WriteLine("{0} ({1})", (int)response.StatusCode, response.ReasonPhrase);}\[/code\]my question is how to pass username and password from C# client to server's api? what I want is when C# client to get whole product list from webapi.client will send username password to server's api. if server's webapi check whether it is authorized user from database, if not dont let it get product list
 
Back
Top