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。

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM