//UserInfoDetail.html
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title></title>
<meta charset="utf-8" />
</head>
<body>
用户名:$name<br />
密码:$pwd<br />
</body>
</html>
/*******************************************************************************************************/
//UserInfoDetail.ashx
<%@ WebHandler Language="C#" Class="UserInfoDetail" %>
using System;
using System.Web;
using System.Text;
using System.IO;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using WebProject.BLL;
using WebProject.Model;
public class UserInfoDetail : IHttpHandler {
public void ProcessRequest (HttpContext context) {
context.Response.ContentType = "text/html";
string filePath = context.Request.MapPath("UserInfoDetail.html");
string fileContent = File.ReadAllText(filePath);
int id;
if (int.TryParse(context.Request.QueryString["UserId"],out id))
{
UserInfoBLL bll = new UserInfoBLL();
UserInfo user = bll.GetUserInfoById(id);
fileContent = fileContent.Replace("$name", user.UserName).Replace("$pwd", user.UserPwd);
context.Response.Write(fileContent);
}
}
public bool IsReusable {
get {
return false;
}
}
}