zoukankan      html  css  js  c++  java
  • [置顶] 判断用户的请求类型 get or post 然后同步 或者 异步 执行 方法

       这个是判断类 根据上下文中得到的 访问类型 。判断执行那个方法

    using System;
    using System.Web;
    
    class HandlerFactory : IHttpHandlerFactory
    {
        public IHttpHandler GetHandler(HttpContext context, 
            string requestType, String url, String pathTranslated)
        {
            IHttpHandler handlerToReturn;
            if ("get" == context.Request.RequestType.ToLower())
            {
                handlerToReturn = new HelloWorldHandler();
            }
            else if ("post" == context.Request.RequestType.ToLower())
            {
                handlerToReturn = new HelloWorldAsyncHandler();
            }
            else
            {
                handlerToReturn = null;
            }
            return handlerToReturn;
        }
        public void ReleaseHandler(IHttpHandler handler)
        {
        }
        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
    
    
    在执行这个类的时候,首先要在web.config中添加一个节点
    <configuration>
      <system.web>
        <httpHandlers>      <add verb="GET,POST" path="*.sample"        type="HandlerFactory" />    </httpHandlers>
      </system.web>
    </configuration>

    
    

    遇见了就不要错过
  • 相关阅读:
    动画差值
    高达模型
    TCP/IP负载均衡
    FreeImage使用
    Game Programming Pattern
    Apple Instruments
    GLEW OpenGL Access violation when using glGenVertexArrays
    微服务了解
    summary
    事务传播行为
  • 原文地址:https://www.cnblogs.com/Traner/p/2819998.html
Copyright © 2011-2022 走看看