CredentialCache

In this chapter you will learn:

  1. How to use CredentialCache to store password

Use CredentialCache to store password

A credential cache contains one or more NetworkCredential objects, each keyed to a particular protocol and URI prefix.

using System;/*  j  a  va2s.  c  o  m*/
using System.Net;
using System.IO;
using System.Linq;
using System.Text;

class Program
{
    static void Main()
    {
        CredentialCache cache = new CredentialCache();
        Uri prefix = new Uri("http://exchange.somedomain.com");
        cache.Add(prefix, "Digest", new NetworkCredential("joe", "passwd"));
        cache.Add(prefix, "Negotiate", new NetworkCredential("joe", "passwd"));

        WebClient wc = new WebClient();
        wc.Credentials = cache;
    }
}

Next chapter...

What you will learn in the next chapter:

  1. Get Address List from HostEntry
Home » C# Tutorial » Network
Cookie
CredentialCache
HostEntry
IPHostEntry
IP address from host name
IPEndPoint from IPAddress
IPEndPoint Port
IPEndPoint properties
IPHostEntry
IP Address Parser
Predefined IP Address
NetworkCredential
Ping
Udp Client
Socket connection
Socket creation
Socket sendTo
TcpClient
TcpListener
UdpClient Receive
UdpClient Sending
Uri
WebClient
Response Headers
WebProxy
WebRequest