public static async Task <HttpClient> GetCookieAdmin(TestServer testServer, string pseudo) { /*CookieContainer cookies = new CookieContainer(); * HttpClientHandler handler = new HttpClientHandler(); * handler.CookieContainer = cookies;*/ //HttpClient client = new HttpClient(handler); HttpClientHandler handler = new HttpClientHandler(); handler.AllowAutoRedirect = true; handler.UseCookies = true; HttpClient client = new HttpClient(handler); client.BaseAddress = testServer.BaseAddress; BddDiStock.CreateUser(pseudo, "admin"); HttpContent content = new FormUrlEncodedContent( new Dictionary <string, string> { { "Pseudo", pseudo }, { "Password", _password } }); var response = await client.PostAsync("/Login", content); return(client); }
public static async Task <string> GetCookieUser(HttpClient client, string pseudo) { BddDiStock.CreateUser(pseudo, "user"); HttpContent content = new FormUrlEncodedContent( new Dictionary <string, string> { { "Pseudo", pseudo }, { "Password", _password }, { "ConfirmPassword", _password } }); var response = await client.PostAsync("/Login", content); return(""); }