为什么我这个验证不成功总是报错,大虾门帮看一下
以下为所报错误:
异常详细信息: System.NullReferenceException: 未将对象引用设置到对象的实例。
源错误:
行 11: protected void Page_Load(object sender, EventArgs e)
行 12: {
行 13: string name = Request.Params["userName"].ToString();
行 14: string pawss = Request.Params["password"].ToString();
行 15:
以下为jquery.js代码:---------------
$.ajax({
type: "POST",
url: "LoginWeb.aspx",
data: "userName=" + name + "&password=" + pass,
datatype: "json",
beforeSend: function() { $("mes").text("登录中....请稍后...."); },
success: function(messges) {
if (messges == "登录成功") {
window.location.href = "mainWeb.aspx";
}
else {
$("mes").text(messges);
}
},
error: function() {
$("mes").text("登录出错,请稍后再试..");
}
});
以下为后台验证代码:-------------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using STBKen.BLL;
public partial class LoginWeb : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string name = Request.Params["userName"].ToString();
string pawss = Request.Params["password"].ToString();
BLLOperator bll = new BLLOperator();
try
{
if (bll.SelectT_appointment_client_userBLL(name, pawss) > 0)
{
Response.Write("登录成功");
}
else
{
Response.Write("用户名和密码不正确");
}
}
catch (Exception ex)
{
Response.Write(ex.Message);
}
}
}
------解决方案--------------------JScript code
data: {userName: name, password: pass}, //这样试试
------解决方案--------------------
打印个 name 值 看看 。有值吗?