Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9287349
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T19:38:52+00:00 2026-06-18T19:38:52+00:00

Perhaps I’m missing something, or perhaps .NET is missing something ( preferably the former

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T19:38:54+00:00Added an answer on June 18, 2026 at 7:38 pm

    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:

    static NetworkCredential ParseBasicAuthorizationHeader(string value)
    {
       if (string.IsNullOrWhiteSpace(value)) 
       {
          return null;
       }
       if (!value.StartsWith("Basic ", StringComparison.OrdinalIgnoreCase)) 
       {
          return null;
       }
    
       byte[] data = Convert.FromBase64String(value.Substring(6));
       value = Encoding.GetEncoding("ISO-8859-1").GetString(data);
    
       int index = value.IndexOf(':');
       if (index == -1 || index == 0 || index == value.Length - 1) 
       {
          return null;
       }
    
       return new NetworkCredential(
          value.Substring(0, index),    // Username
          value.Substring(index + 1));  // Password
    }
    

    Bear in mind that, like all other HTTP headers, the Authorization header is completely controlled by the client, and should therefore be treated as untrusted user input.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Perhaps I'm missing something but when I scan an NFC tag via a galaxy
Perhaps I'm missing something here, but it seems that anything in the object model
Perhaps this is mere wishful thinking, but is there a simple way (in ASP.NET)
Perhaps I'm missing something here, but I want the user to be able to
Perhaps not such a big deal, but it breaks my heart to follow this:
Perhaps a dump question (But I'm not a super experienced user of .NET), but
Perhaps I am missing something but how does one go about retrieving the xml
Perhaps I'm missing something major, but is there a way to use Object.watch() on
Perhaps I am missing something from the Knockout.js tutorial, but I find it a
Perhaps I'm missing something obvious here, but I'm having a hard time setting a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.