Perhaps I’m missing something, or perhaps .NET is missing something (preferably the former)
When building an application (not exclusively ASP.NET, but such is my situation; specifically an ASP.NET hosted WCF DS) it seems there’s no native way to create a NetworkCredential object from an HttpRequest, or any similar request/header container,.
Do we always have to roll our own, or is there some magic tucked away in System.Net.* or System.Web.* with a signature like:
NetworkCredential GetAuthorization(HttpRequest request);
It’s trivial I know, but I would assume something standard to the HTTP architecture would be included in something that is otherwise so encompassing (.NET)
So, home-brew string manipulation, or magic method hiding somewhere?
I don’t think there’s anything built-in; it would be of limited use, since most clients use Kerberos or Digest authentication instead.
However, it’s fairly simple to roll your own:
Bear in mind that, like all other HTTP headers, the
Authorizationheader is completely controlled by the client, and should therefore be treated as untrusted user input.