C# 一般处理程序

public class Three : IHttpHandler{
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            context.Response.Write("Hello World");
            context.Response.Write("sss");
        } 
    }
public void ProcessRequest (HttpContext context) {     请求过来找到该一般处理程序文件,自动执行ProcessRequest方法。
        context.Response.ContentType = "text/html";
        //获取要操作的模板的路径.
        string filePath = context.Request.MapPath("ShowInfo.html");//获取文件的物理路径。在Asp.net中,对文件或文件夹进行操作一定要获取物理路径。
        //读取模板文件中的内容。
       string fileContent=File.ReadAllText(filePath);
        //用户具体的数据替换模板文件中的展位符。
       fileContent = fileContent.Replace("$name","itcast").Replace("$pwd","123");
        //将替换后的内容输出给浏览器。
       context.Response.Write(fileContent);
       context.Response.Write("<b>adfsdf</b>");

    context.Response.Write(System.Reflection.Assembly.GetExecutingAssembly().Location); }
$(function () {
            $(".deletes").click(function () {
                if (!confirm("确定要删除吗?")) {
                    return false;
                }
            });
        });
string userName=context.Request.QueryString["txtName"];//接收的是表单元素name属性的值
string userPwd=context.Request.QueryString["txtPwd"];
string userName = context.Request.Form["txtName"];
string userPwd = context.Request.Form["txtPwd"];

IIS会根据请求的文件类型进行判断,如果发现浏览器请求的是动态文件(ashx) IIS是处理

不了的,会将请求的文件交给.netframework来执行,IIS是通过aspnet.isapi.dll来把请求的

动态文件交给.netframework。

猜你喜欢

转载自www.cnblogs.com/escapist/p/9672059.html