Andreas
Andreas

Reputation: 7248

How to get the basic HTTP authentication data in ASP.NET

Where do I find the basic HTTP authentication credentials (username and password) in the incoming request to my server?

Is it somewhere in the Request object, or is there some other way to get them?

Running: IIS 7 - ASP.NET - .NET Framework 4 - C#

Upvotes: 2

Views: 6298

Answers (1)

AdaTheDev
AdaTheDev

Reputation: 147314

Basic authentication details will be in the Request.Headers, with the key: "Authorization"

It's a base64 encoded string, which you'll need to decode. Check out this post, there's a code sample in there that demonstrates picking that header apart.

Upvotes: 3

Related Questions