前端页面
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="ajax。aspx。cs" Inherits="About_ajax" %> Jquery Ajax实例
ashx文件使用代码
<%@ WebHandler Language="C#" Class="AjaxHandler" %> using System; using System.Web; public class AjaxHandler : IHttpHandler { public void ProcessRequest (HttpContext context) { //context.Response.ContentType = "text/plain"; //context.Response.Write("Hello World"); context.Response.ContentType = "text/plain"; //context.Response.Write("Hello World"); if (context.Request["name"].ToString() == "admin" && context.Request["pass"].ToString() == "admin") { context.Response.Write("Y"); } else { context.Response.Write("N"); } } public bool IsReusable { get { return false; } } [System.Web.Services.WebMethod] public static string SayHello() { return "Hello Ajax! AjaxHandler。ashx"; } }
<%@ WebHandler Language="C#" Class="S_CBFBM" %> using System; using System.Web; / /// 功能:获取 编号 /// public class S_CBFBM : IHttpHandler { public void ProcessRequest (HttpContext context) { context.Response.ContentType = "text/plain"; string zbm=context.Request["ZBM"].ToString(); zbm=zbm.Trim(); if(zbm!="") { string cbfbm = zbm + "001"; context.Response.Write(cbfbm); } else { context.Response.Write(""); } } public bool IsReusable { get { return false; } } [System.Web.Services.WebMethod] public static string SayHello() { return "Hello Ajax! S_CBFBM。ashx"; } }
文章转载自: ashx 文件怎么用 http://www.studyofnet.com/news/286.html
发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/208773.html原文链接:https://javaforall.net
