Click here to Skip to main content
15,905,028 members
Home / Discussions / C#
   

C#

 
Generalcapturing events when application closes Pin
vista2713-Jul-04 7:59
vista2713-Jul-04 7:59 
GeneralRe: capturing events when application closes Pin
Heath Stewart13-Jul-04 9:07
protectorHeath Stewart13-Jul-04 9:07 
GeneralArray of Struct within Struct Pin
Uday Shastri13-Jul-04 7:58
Uday Shastri13-Jul-04 7:58 
GeneralRe: Array of Struct within Struct Pin
Heath Stewart13-Jul-04 9:21
protectorHeath Stewart13-Jul-04 9:21 
GeneralRe: Array of Struct within Struct Pin
Uday Shastri13-Jul-04 9:47
Uday Shastri13-Jul-04 9:47 
GeneralRe: Array of Struct within Struct Pin
Heath Stewart13-Jul-04 10:19
protectorHeath Stewart13-Jul-04 10:19 
Generalupload files Pin
Steven M Hunt13-Jul-04 7:03
Steven M Hunt13-Jul-04 7:03 
GeneralRe: upload files Pin
Heath Stewart13-Jul-04 9:17
protectorHeath Stewart13-Jul-04 9:17 
Yes - by using the Credentials property and assigning an ICredentials implementation. If you're using CredentialCache.DefaultCredentials, then it probably won't work unless you're connecting to a site that requires NTLM authentication with your domain account (which is about all that would be in the DefaultCredentialss).

Instead, create a new instance of the CredentialCache to hold multiple credentials, or just a NetworkCredential to hold a single credential.

If you look at the class documentation for the CredentialCache class in the .NET Framework SDK (installed by default with VS.NET), it even gives an example of using both classes mentioned above. For the former, you instantiate a new NetworkCredential and add it to a CredentialCache associated with a given Uri and specifying the authentication type ("Digest", "NTLM", "Kerberos", etc.).

If you wanted to download a file from www.domain.com with username:password, you'd do something like this:
WebClient client = new WebClient();
CredentialCache cache = new CredentialCache();
cache.Add(new Uri("http://www.domain.com/"), "Basic",
  new NetworkCredential("username", "password", "DOMAIN")));
client.Credentials = cache;
client.DownloadFile("http://www.domain.com/file.txt", "file.txt");
Read the documentation for NetworkCredential to see what password schemes are supported. You can add additional schemes, if necessary, by implementing the IAuthenticationModule, also - of course - documented in the .NET Framework SDK.

 

Microsoft MVP, Visual C#
My Articles
GeneralRe: upload files Pin
Steven M Hunt14-Jul-04 14:31
Steven M Hunt14-Jul-04 14:31 
GeneralRe: upload files Pin
Heath Stewart19-Jul-04 2:02
protectorHeath Stewart19-Jul-04 2:02 
Generalstruct question Pin
ConfusedAsHeck13-Jul-04 5:30
sussConfusedAsHeck13-Jul-04 5:30 
GeneralRe: struct question Pin
Tom Larsen13-Jul-04 5:34
Tom Larsen13-Jul-04 5:34 
GeneralRe: struct question Pin
Heath Stewart13-Jul-04 6:11
protectorHeath Stewart13-Jul-04 6:11 
GeneralAccessing Forms Pin
Mehbub13-Jul-04 5:02
Mehbub13-Jul-04 5:02 
GeneralRe: Accessing Forms Pin
Tom Larsen13-Jul-04 5:27
Tom Larsen13-Jul-04 5:27 
GeneralRe: Accessing Forms Pin
Colin Angus Mackay13-Jul-04 6:03
Colin Angus Mackay13-Jul-04 6:03 
GeneralRe: Accessing Forms Pin
Dave Kreskowiak13-Jul-04 12:46
mveDave Kreskowiak13-Jul-04 12:46 
GeneralRe: Accessing Forms Pin
Weiye Chen13-Jul-04 19:36
Weiye Chen13-Jul-04 19:36 
GeneralRe: Accessing Forms Pin
Weiye Chen13-Jul-04 20:52
Weiye Chen13-Jul-04 20:52 
GeneralViewing Exported Functions and Parameters in a DLL Pin
Mr. Rogers13-Jul-04 4:22
Mr. Rogers13-Jul-04 4:22 
GeneralRe: Viewing Exported Functions and Parameters in a DLL Pin
Heath Stewart13-Jul-04 4:33
protectorHeath Stewart13-Jul-04 4:33 
GeneralRe: Viewing Exported Functions and Parameters in a DLL Pin
Mr. Rogers13-Jul-04 4:51
Mr. Rogers13-Jul-04 4:51 
QuestionHow to get the time from a computer Pin
Stuggo13-Jul-04 4:11
Stuggo13-Jul-04 4:11 
AnswerRe: How to get the time from a computer Pin
Heath Stewart13-Jul-04 4:20
protectorHeath Stewart13-Jul-04 4:20 
GeneralResponse.Redirect is not working.. a peculiar problem..One solution found !! Pin
PhaniKatakam13-Jul-04 2:07
PhaniKatakam13-Jul-04 2:07 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.