zoukankan      html  css  js  c++  java
  • ajax异步请求的ashx页面

    首先创建一般处理程序,也就是ashx 文件

    然后就是要让异步请求的数据不被浏览器缓存

    其次获得请求的参数

    再次根据参数进行具体的业务逻辑操作

    最后返回响应的字符串

    下面给出一个简单的例子

    using System;
    using System.Collections;
    using System.Data;
    using System.Linq;
    using System.Web;
    using System.Web.Services;
    using System.Web.Services.Protocols;
    using System.Xml.Linq;

    namespace WXWebTest.AJAX
    {
    /// <summary>
    /// $codebehindclassname$ 的摘要说明
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    public class Test : IHttpHandler
    {

    public void ProcessRequest(HttpContext context)
    {
    context.Response.ContentType = "text/plain";
    context.Response.Buffer = true;//缓存输出
    #region 禁用浏览器缓存
    context.Response.ExpiresAbsolute = DateTime.Now.AddDays(-1);
    context.Response.AddHeader("pragma", "no-cache");
    context.Response.AddHeader("cache-control", "");
    context.Response.CacheControl = "no-cache";
    #endregion
    string result = "";
    string qs = context.Request.Params["a"];//获取参数 可以根据参数进行具体的业务
    result = qs + "hello world";//具体的ToDo部分可以在这里
    context.Response.Write(result);
    }

    public bool IsReusable
    {
    get
    {
    return false;
    }
    }
    }
    }
  • 相关阅读:
    jsp标签${fn:contains()}遇到问题记录
    maven更改本地的maven私服
    elk使用记录
    dubbo 报错问题记录:may be version or group mismatch
    mybatis自动生成后无法获取主键id问题
    tomcat关闭异常导致的项目无法重启
    jsp 记录
    spring bean
    JDBC
    el表达式
  • 原文地址:https://www.cnblogs.com/wxzl/p/2287420.html
Copyright © 2011-2022 走看看