后台由一般处理程序(Httphandler)读取前台网页提交的数据。
一般处理程序必须实现HttpHandler接口
public class LoginHandler:IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType="text/plain";
//获取网页前台提交的数据
string username=context.Request.Params["username"];
string pwd=context.Request.Params["pwd"];
//调用数据库访问方法判断用户名和密码是否正确
AdminLoginService loginService=new AdminLoginService();
if(loginService.Login(username,pwd))
{
context.Response.Write("登录成功!");
}
else
{
context.Response.Write("用户名或密码错误!");
}
}
}
继承了HttpHandler接口的类具备了接受和数据的能力。