Credentials Modification

Oct 24, 2008 at 6:09 PM

I've noticed quite a few people asking about credentials modifications.

For Forms Authentication out

Here is a modification I used to add credentials to the Web Request.

In HtmlWeb.cs:
1.) create the following private fields: 



private string _userName;



private string _password;

2.) Create a new constructor:  



public HtmlWeb(string userName, string password)



_userName = userName;

_password = password;


3.) Add the following to the HttpStatusCode Get() method



HttpStatusCode Get(Uri uri, string method, string path, HtmlDocument doc)







if(!string.IsNullOrEmpty(_userName) && !string.IsNullOrEmpty(_password))



req.Credentials =

new NetworkCredential(_userName, _password);