http post request login example asp.net c#
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#:
- Title
- show double in textbox c#
- Category
- C#
- Title
- c# how to have a multiline console.writeline
- Category
- C#
- Title
- find gameobject with tag
- Category
- C#
- Title
- add mime type for woff in web.config
- Category
- C#
- Title
- eventos c#
- Category
- C#
- Title
- C# get all files in directory
- Category
- C#
- Title
- idbset sqlquery
- Category
- C#
- Title
- xml node update attribute value c#
- Category
- C#
- Title
- c# Authorization has been denied for this request
- Category
- C#
- Title
- c# math to radiant
- Category
- C#
- Title
- while loop in c#
- Category
- C#
- Title
- change z value unity
- Category
- C#
- Title
- c# image to byte array
- Category
- C#
- Title
- repeater itemdatabound event in c#
- Category
- C#
- Title
- unity gizmo draw line
- Category
- C#
- Title
- c# ramdom
- Category
- C#
- Title
- C# array index tostring
- Category
- C#
- Title
- html hidden text
- Category
- C#
- Title
- decalre an int list mvc
- Category
- C#
- Title
- c# creating exceptions
- Category
- C#
- Title
- use enter key unity
- Category
- C#
- Title
- how do i foreach c#
- Category
- C#
- Title
- file picker uwp c#
- Category
- C#
- Title
- asp.net list all files in folder
- Category
- C#
- Title
- unity remove parent
- Category
- C#
- Title
- get number of sundays in a month c#
- Category
- C#
- Title
- unity material offset script
- Category
- C#
- Title
- linq in c#
- Category
- C#
- Title
- c# generate random number
- Category
- C#
- Title
- unity load text resources from subfolder
- Category
- C#
- Title
- c# distinct comparer multiple properties
- Category
- C#
- Title
- new command - latex
- Category
- C#
- Title
- how to stop player rotating when hit by object
- Category
- C#
- Title
- how to spawn coins randomly around the screen unity 2d
- Category
- C#
- Title
- convert string to decimal c#
- Category
- C#
- Title
- check if string is email c#
- Category
- C#
- Title
- datagridview select row column cell c#
- Category
- C#
- Title
- c sharp list indexer
- Category
- C#
- Title
- order by C#
- Category
- C#
- Title
- c# zip a file
- Category
- C#
- Title
- orderby make sunday last day c#
- Category
- C#
- Title
- socket in c#
- Category
- C#
- Title
- how to set progress openedge driver name for odbc connection c#
- Category
- C#
- Title
- how to cast list to observablecollection c#
- Category
- C#
- Title
- C# type cast float to string
- Category
- C#
- Title
- c# two dimensional array
- Category
- C#
- Title
- unity create primitive
- Category
- C#
- Title
- How to get number of months between 2 dates c#
- Category
- C#
- Title
- unity get velocity at point
- Category
- C#
- Title
- get user directory of file in c#
- Category
- C#
- Title
- unity ai wander script
- Category
- C#
- Title
- c# return two variables of different types
- Category
- C#
- Title
- how to work with ascii in c#
- Category
- C#
- Title
- wpf use enum description
- Category
- C#
- Title
- c# get time
- Category
- C#
- Title
- csharp datetime string format
- Category
- C#
- Title
- bool toggle unity c#
- Category
- C#
- Title
- c# get list of all class fields
- Category
- C#
- Title
- how to track a branch on github
- Category
- C#
- Title
- unity 2d joystick controls
- Category
- C#
- Title
- c# System.Resources.MissingManifestResourceException error
- Category
- C#
- Title
- call Textboxfor in cs
- Category
- C#
- Title
- use newtonsoft json to clone object
- Category
- C#
- Title
- unity clamp rotation
- Category
- C#
- Title
- asp list box
- Category
- C#
- Title
- unity fall damage c#
- Category
- C#
- Title
- modificare una strinfa in c#
- Category
- C#
- Title
- C# linq mselect
- Category
- C#
- Title
- vb.net tostring numeric format string
- Category
- C#
- Title
- freeze position unity c#
- Category
- C#
- Title
- call a function c#
- Category
- C#
- Title
- trello
- Category
- C#
- Title
- c# getter setter
- Category
- C#
- Title
- c# find element by condition
- Category
- C#
- Title
- how to add system.messaging c#
- Category
- C#
- Title
- asp.net tag helper checkbox
- Category
- C#
- Title
- how to convert iformfile to byte array c#
- Category
- C#
- Title
- c# thread sleep
- Category
- C#
- Title
- create new object from generic c#
- Category
- C#
- Title
- how to clear console in c#
- Category
- C#
- Title
- c# .net core memory cache
- Category
- C#
- Title
- list clone - C#
- Category
- C#
- Title
- c# move with arrow keys
- Category
- C#
- Title
- .sh script: check if file exist
- Category
- C#
- Title
- c# webrequest cookies
- Category
- C#
- Title
- binding c#
- Category
- C#
- Title
- find negative version of integer in c#
- Category
- C#
- Title
- c# timespan
- Category
- C#
- Title
- C# Into To Tring Debug.Log
- Category
- C#
- Title
- unity make a int arry with preset values
- Category
- C#
- Title
- snake game
- Category
- C#
- Title
- unity monobehaviour
- Category
- C#
- Title
- c# enum default
- Category
- C#
- Title
- how to parse a string to an integer c#
- Category
- C#
- Title
- c# generic abstract method
- Category
- C#
- Title
- unity jump
- Category
- C#
- Title
- check which activity in focus in android
- Category
- C#
- Title
- navigate to another page with an object uwp c#
- Category
- C#
- Title
- razor preview
- Category
- C#
- Title
- c# httpclient azure function authorization
- Category
- C#