ASP.Net-基本CRUD-APP 详情查询

本文介绍了一个简单的Web应用,用于展示特定用户的详细信息,如用户名和密码等。通过读取HTML模板文件,并利用C#后端从数据库中获取指定ID的用户信息来动态填充模板。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

//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;
        }
    }

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值