Get or set a Boolean value that controls whether the DefaultCredentials are sent with requests in CSharp

Description

The following code shows how to get or set a Boolean value that controls whether the DefaultCredentials are sent with requests.

Example


using System;/*  w  w w  . j  av a  2  s .c  om*/
using System.Net;
using System.Net.Sockets;

public class Example
{
    public static void Main()
    {
        WebClient client = new WebClient();

        Uri uri = new Uri("http://www.Yourfakeserver.com/fileUpload.aspx");

        client.UseDefaultCredentials = true;
        Console.WriteLine("File upload started.");

    }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    Network »




IP
Web Client