private void Button_Click_1(object sender, RoutedEventArgs e)
{
WebClient wb = new WebClient();
wb.DownloadStringCompleted += new DownloadStringCompletedEventHandler(wb_DownloadStringCompleted);
wb.DownloadStringAsync(new Uri("http://localhost:49380/Extension/Handler1.ashx?UserName=" + this.txtUserName.Text + "&Psw=" + this.txtPsw.Text));
} void wb_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
{
MessageBox.Show(e.Result.ToString());
}
public class Handler1 : IHttpHandler
{ public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "text/plain";
// context.Response.Write("Hello World"); string userName = context.Request["UserName"];
string psw = context.Request["Psw"];
if (userName == "Admin" && psw == "")
{
context.Response.Write("登陆成功");
}
else
{
context.Response.Write("登陆失败");
} } public bool IsReusable
{
get
{
return false;
}
}