本帖最后由 medal8 于 2014-3-19 21:16 编辑
我做一个登录,登录地址:http://search1.library.sh.cn/mylibrary/html/reader_login.htm,页面的验证码我是先通过IE访问,产生之后写死在代码里,用户名:03000306,用户密码:310225198307296617,
登录的代码如下:
[C#] 纯文本查看 复制代码
/// <summary>
/// 读者登录
/// </summary>
/// <param name="i_reader_no"></param>
/// <param name="i_body_card"></param>
/// <returns></returns>
public ReaderInfo LoginReader(string i_reader_no, string i_body_card)
{
string t_login_post_data = string.Format("_language_=zh&login_button.x=45&login_button.y=24user.cardNo={0}&user.identityNo={1}&user.captchacode={2}",
i_reader_no, i_body_card, "4544");
HttpItem t_login_item = new HttpItem();
t_login_item.ContentType = "application/x-www-form-urlencoded";
t_login_item.URL = AppConfig.SHReaderUrl;
t_login_item.Postdata = t_login_post_data;
t_login_item.Method = "POST";
t_login_item.IsToLower = false;
t_login_item.ResultType = ResultType.String;
HttpHelper httpHelper = new HttpHelper();
try
{
HttpResult httpResult = httpHelper.GetHtml(t_login_item);
string t_cookie = httpResult.Cookie;
string result = httpResult.Html;
result = result.Replace("\r", "").Replace("\n", "").Replace("\r\n", "");
if (result == "String Error")
return null;
return null;
}
catch (Exception ex)
{
LogHelper.Error("读者登录失败" + ex.ToString());
return null;
}
}
返回的cookie为:JSESSIONID=D373E985E68F8BC7CE5CEF1EE28D75B1; Path=/mylibrary
返回的HTML始终是登录失败的页码代码:
[HTML] 纯文本查看 复制代码
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>我的图书馆</title>
<style type="text/css">
<!--
body {
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
}
-->
</style>
<link href="../images/css.css" rel="stylesheet" type="text/css" />
</head>
<body>
<form action="../application/setReaderInfo" method="post" id="form">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="78" align="left" background="../images/index_01.jpg"><div align="left"><img src="../images/index_02.jpg" width="231" height="78" alt="" /></div></td>
</tr>
<tr>
<td align="center" valign="top"><table width="958" border="0" cellspacing="0" cellpadding="0" >
<tr>
<td valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="right" valign="top"><table width="777" cellpadding="0" cellspacing="0" class="table_1" >
<tr >
<td ><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="30" bgcolor="#d2eff5"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="1%"> </td>
<td width="99%" class="top_black"><div align="left"> 提示信息</div></td>
</tr>
</table></td>
</tr>
<tr>
<td height="10" align="center"> </td>
</tr>
<tr>
<td align="center" colspan=""><table width="72%" border="0" cellspacing="0" cellpadding="0" height="400px">
<tr>
<td width="91%" class="td_left">
<strong>请<font class="font4"><a href="../html/reader_login.htm">点击此处</a></font>登录系统!</strong>
</td>
</tr>
</table></td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td> </td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td height="45" align="center" valign="top" background="../images/index_40.jpg"><iframe src="../jsp/blew.jsp" name="I1" width="100%" height="45" scrolling="no" frameborder="0" id="I1" border="0"> 浏览器不支持嵌入式框架,或被配置为不显示嵌入式框架。</iframe></td>
</tr>
</table>
</form>
</body>
</html>
请高手指教下是什么问题,页面的源代码我猜测后台是没做校验的,是前端校验的,因为验证码是JS产生的,没写cookie。 |