http post request login example asp.net c#
using System;
using System.Text;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Threading.Tasks;
namespace HttpClientAuth
{
class Program
{
static async Task Main(string[] args)
{
var userName = "user7";
var passwd = "passwd";
var url = "https://httpbin.org/basic-auth/user7/passwd";
using var client = new HttpClient();
var authToken = Encoding.ASCII.GetBytes($"{userName}:{passwd}");
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic",
Convert.ToBase64String(authToken));
var result = await client.GetAsync(url);
var content = await result.Content.ReadAsStringAsync();
Console.WriteLine(content);
}
}
}
Also in C#:
- datatable return column names
- check distance to gameobject
- for c#
- c# linq to get most recent item from IList
- unity next scene
- create new object from generic c#
- float to int c#
- generic repository pattern c#
- c# filter non alphanumeric characters
- page parent wpf
- get enum by index c#
- unity how to set an objects postion x,y,z
- to list c#
- c# input integer
- c# how to run external program
- unity instantiate an object
- unity particle system color
- c# size of enum
- switch case c# range
- leantween id
- how to allow user import image c#
- c# half hour dropdown list
- read embedded resource c# xml
- c# list tuple