写了个处理程序,但是不懂这里怎么连接 数据 库,请教 一下,我是使用LINQ TO SQL 类来做的 ,建了一个mydata.dbml类,比如 我要连接到数据 库express 中的usertable表,应该 怎么改进,下面这个是写死的
namespace MyLogin.Ajax
{
/// <summary>
/// Summary description for LoginHandler
/// </summary>
public class LoginHandler : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
context.Response.Buffer = true;
context.Response.ExpiresAbsolute = DateTime.Now.AddDays(-1);
context.Response.AddHeader("pragma", "no-cache");
context.Response.AddHeader("cache-control", "");
context.Response.CacheControl = "no-cache";
context.Response.ContentType = "text/plain";
string username = context.Request["username"].ToString();
string password = context.Request["password"].ToString();
//context.Response.Write(password);
//这里怎么进行 数据 库连接 ,请教
if (username == "admin" && password == "1")
{
context.Response.Write("success");
//存储session
}
else
{
context.Response.Write("fail");
}
//context.Response.Write("Hello World");
}
public bool IsReusable
{
get
{
return false;
}
}
}
}