</pre>前台html页面通过JQuery的AJAX方式向ashx页面传递值</p><p>形式如下:</p><p></p><pre name="code" class="javascript">$.post('Service/GetData.ashx', { "username": $("#ipt_username").val(), "userpwd": $("#ipt_userpwd").val(), },
//$.post('http://127.0.0.1:3722/users/check', { "username": $("#ipt_username").val(), "userpwd": $("#ipt_userpwd").val() },
function (a) {
if (a == "True!")
{
$.messager.alert('提示', '登录成功!', 'info')
setCookie('username', 'gisera');
formLogin.dialog('close');
}
else
{
$.messager.alert('提示', '登录失败!', 'info');
}
}
)
然后service服务里面的ashx页面获取传入的值,都在HttpContent这个密封静态类中
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "text/plain";
string name = context.Request.Form[0];
string pwd = context.Request.Form[1];
Common.DEncrypt.EncryptRe pwd1 = new Common.DEncrypt.EncryptRe();
string b = pwd1.EncryptString(pwd);
try
{
if (GetUserSignIn(name, pwd).Rows[0][0].ToString() == b) //返回验证用户登录的状态 True或False
{
context.Response.Write("True!");
}
else
{
context.Response.Write("False!");
}
}
catch { context.Response.Write("False!"); }
}
public static System.Data.DataTable GetUserSignIn(string name, string pwd)
{
}
public bool IsReusable
{
get
{
return false;
}
}
附:GetUserSignIn为加密算法 进行匹配,返回输出形式是content.response.write
返回的值被JQuery中的function(a)中a接收到然后进行判断。
附:64位系统后台通过ado.net连接Oracle出现无法检测到Oracle的情况,比较好的解决办法是在64位系统中装32位oracle,因为PL/sql没有64位版,然后设置环境变量讲oracle的path路径放在最前,然后到oracle目录下添加用户完全控制的权限,重启IIS,重启VS。