c# - Programatiically login to a website that uses IIS authentication -


hi trying login website programmatically.i have worked on php page , used below code (found on stack overflow) login , worked great.

 private static string getdatafromphp(string formurl, string geturl, string username, string password, out bool status)         {              try             {                  string formparams = string.format("access_login={0}&access_password={1}", username, password);                 string cookieheader;                 webrequest req = webrequest.create(formurl);                 req.contenttype = "application/x-www-form-urlencoded";                 req.method = "post";                 byte[] bytes = encoding.ascii.getbytes(formparams);                 req.contentlength = bytes.length;                 using (stream os = req.getrequeststream())                 {                     os.write(bytes, 0, bytes.length);                 }                  webresponse resp = req.getresponse();                 cookieheader = resp.headers["set-cookie"];                 string pagesource;                  webrequest getrequest = webrequest.create(geturl);                 getrequest.headers.add("cookie", cookieheader);                 webresponse getresponse = getrequest.getresponse();                 using (streamreader sr = new streamreader(getresponse.getresponsestream()))                 {                     pagesource = sr.readtoend();                 }                 status = true;                  return pagesource;             }                catch (system.exception ex)             {                 status = false;                 return string.empty;             }          } 

where access_login & access_password name of input box accepts credentials.i have no clue how implement iis login prompt shown below.please help

enter image description here

if can login through browser , use fiddler intercept request, can use fiddler add-on request-to-code generate c# code perform request. generated code place start @ least.

i have used fiddler request-to-code in similar situations.


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -