ASP FirstWeb

//html

<!DOCTYPE html>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title></title>
<meta charset="utf-8" />
</head>
<body>
    <table>
        <tr>
            <td>用户名</td>
            <td>$UserName</td>
        </tr>
        <tr>
            <td>密码</td>
            <td>$UserPwd</td>
        </tr>
    </table>
</body>

</html>


//.ashx

<%@ WebHandler Language="C#" Class="List" %>


using System;
using System.Web;


public class List : IHttpHandler {


    public void ProcessRequest (HttpContext context) {
        context.Response.ContentType = "text/html";
        string filePath = context.Request.MapPath("List.html");
        string fileContent = System.IO.File.ReadAllText(filePath);
        fileContent = fileContent.Replace("$UserName", "zhangsan").Replace("$UserPwd", "123456");
        context.Response.Write(fileContent);



    }


    public bool IsReusable {
        get {
            return false;
        }
    }


}

posted @ 2018-04-18 22:53  dxm809  阅读(73)  评论(0编辑  收藏  举报