Click here to Skip to main content
15,899,937 members
Home / Discussions / C#
   

C#

 
GeneralRe: cool icons Pin
RNEELY25-Feb-04 9:16
RNEELY25-Feb-04 9:16 
GeneralRe: cool icons Pin
OmegaSupreme25-Feb-04 9:27
OmegaSupreme25-Feb-04 9:27 
GeneralDynamic display of datagrids with Checkboxes Integrated Pin
Ananthanatarajan25-Feb-04 6:36
Ananthanatarajan25-Feb-04 6:36 
GeneralRe: Dynamic display of datagrids with Checkboxes Integrated Pin
Heath Stewart25-Feb-04 7:23
protectorHeath Stewart25-Feb-04 7:23 
GeneralRuntime user code Pin
Joel Holdsworth25-Feb-04 6:28
Joel Holdsworth25-Feb-04 6:28 
GeneralRe: Runtime user code Pin
Heath Stewart25-Feb-04 6:59
protectorHeath Stewart25-Feb-04 6:59 
GeneralHttpWebRequest authentication Pin
godzooky25-Feb-04 4:23
godzooky25-Feb-04 4:23 
GeneralRe: HttpWebRequest authentication Pin
Heath Stewart25-Feb-04 5:20
protectorHeath Stewart25-Feb-04 5:20 
If you get a 401, the correct procedure is to either pass credentials or prompt if you don't have them. So, lets say you have a while (or for) loop (it's good to terminate it at some point). If you get a 401, prompt the user with a Form you could easily create that asks for a username and password (don't forget to set the PasswordChar on the password TextBox). Then, create an instance of an ICredentials implementation - like NetworkCredentials which is provided in the .NET base class libraries - and assign that instance as your HttpWebRequest.Credentials property. You may want to keep that once you get a 200 (or something besides 401 or another error) response.

If you're running on Windows XP or newer, you can use DPAPI to store the password, which is a Windows facility for storing network and Internet (including Passport) credentials. There's a pretty good article about it on MSDN at http://msdn.microsoft.com/library/en-us/dnnetsec/html/dpapiusercredentials.asp[^]. This isn't required for a solution, though, just more of a nicety for users (and alliviates the burden on you of securely caching passwords for remote resources if you choose to support it).

 

Microsoft MVP, Visual C#
My Articles
GeneralRe: HttpWebRequest authentication Pin
godzooky25-Feb-04 5:36
godzooky25-Feb-04 5:36 
GeneralRe: HttpWebRequest authentication Pin
Heath Stewart25-Feb-04 6:23
protectorHeath Stewart25-Feb-04 6:23 
GeneralSome questions about webservice Pin
Forrest Feather25-Feb-04 4:16
Forrest Feather25-Feb-04 4:16 
GeneralRe: Some questions about webservice Pin
Heath Stewart25-Feb-04 5:05
protectorHeath Stewart25-Feb-04 5:05 
GeneralRe: Some questions about webservice Pin
Forrest Feather25-Feb-04 14:10
Forrest Feather25-Feb-04 14:10 
QuestionThreads? Pin
johnstacey25-Feb-04 0:00
johnstacey25-Feb-04 0:00 
AnswerRe: Threads? Pin
Verdant12325-Feb-04 2:36
Verdant12325-Feb-04 2:36 
AnswerRe: Threads? Pin
scadaguy25-Feb-04 2:58
scadaguy25-Feb-04 2:58 
GeneralRe: Threads? Pin
johnstacey25-Feb-04 11:16
johnstacey25-Feb-04 11:16 
AnswerRe: Threads? - Another Question Pin
johnstacey25-Feb-04 11:30
johnstacey25-Feb-04 11:30 
Generalremoting/serialization problem Pin
occcy24-Feb-04 22:50
occcy24-Feb-04 22:50 
GeneralRe: remoting/serialization problem Pin
Heath Stewart25-Feb-04 5:01
protectorHeath Stewart25-Feb-04 5:01 
GeneralRe: remoting/serialization problem Pin
occcy25-Feb-04 20:39
occcy25-Feb-04 20:39 
GeneralRe: remoting/serialization problem Pin
Heath Stewart26-Feb-04 2:58
protectorHeath Stewart26-Feb-04 2:58 
GeneralRe: remoting/serialization problem Pin
occcy26-Feb-04 3:11
occcy26-Feb-04 3:11 
GeneralRe: remoting/serialization problem Pin
Heath Stewart26-Feb-04 3:31
protectorHeath Stewart26-Feb-04 3:31 
GeneralRe: remoting/serialization problem Pin
occcy26-Feb-04 4:19
occcy26-Feb-04 4:19 

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.