我試圖在Windows 8商店應用程序中使用HttpWebRequest登錄網站。登錄形式如下:HttpWebRequest用隱藏輸入登錄
<form method="post" action="" onsubmit="javascript:return FormSubmit();">
<div>
<div>
<span>gebruikersnaam</span>
<input size="17" type="text" id="username" name="username" tabindex="1" accesskey="g" />
</div>
<div>
<span>wachtwoord</span>
<input size="17" type="password" id="password" name="password" maxlength="48" tabindex="2" accesskey="w" autocomplete="off" />
</div>
<div class="controls">
<input type="submit" id="submit" accesskey="l" value="inloggen" tabindex="4" class="button"/>
</div>
<!-- The following hidden field must be part of the submitted Form -->
<input type="hidden" name="lt" value="_s3E91853A-222D-76B6-16F9-DB4D1FD397B7_c8424159E-BFAB-EA2A-0576-CD5058A579B4" />
<input type="hidden" name="_eventId" value="submit" />
<input type="hidden" name="credentialsType" value="ldap" />
</div>
</form>
我能發出最需要的投入,除了命名爲「LT」隱藏的輸入。這是一個隨機生成的代碼用於安全目的,所以我不能在我的腳本中對其進行硬編碼。我目前的腳本是這樣的:
HttpWebRequest loginRequest2 = (HttpWebRequest)WebRequest.Create(LOGIN_URL_REDIRECT);
loginRequest2.CookieContainer = CC;
loginRequest2.Method = "POST";
loginRequest2.Accept = "image/gif, image/jpeg, image/pjpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, application/x-ms-application, application/x-ms-xbap, application/vnd.ms-xpsdocument, application/xaml+xml, */*";
loginRequest2.ContentType = "application/x-www-form-urlencoded";
loginRequest2.Headers["Accept-Encoding"] = "gzip,deflate";
loginRequest2.Headers["Accept-Language"] = "en-us";
StreamWriter sw = new StreamWriter(await loginRequest2.GetRequestStreamAsync());
sw.Write("username=" + userName + "&password=" + passWord + "&_eventId=submit&credentialsType=ldap");
await sw.FlushAsync();
HttpWebResponse response2 = (HttpWebResponse)await loginRequest2.GetResponseAsync();
在做請求之前,我如何獲得隱藏輸入「lt」的te內容?