zoukankan      html  css  js  c++  java
  • 一般处理程序

    不同平台之间通信,可以选择web server,TCP,UDP,一般处理程序,WEBAPI等等等等 不要跑

    但是我一个都不会。慌死我了,怎么办怎么办怎么办................

    我的一般处理程序都是依附在网页上面,网页上的按钮点击以后用action跳转到一般处理程序,然后一般处理程序会自动运行ProcessRequest方法。

    网页代码:

     

    [html] view plain copy
     
     print?在CODE上查看代码片派生到我的代码片
    1. <!DOCTYPE html>  
    2. <html xmlns="http://www.w3.org/1999/xhtml">  
    3. <head>  
    4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>  
    5.     <title></title>  
    6. </head>  
    7. <body>  
    8.     <form method="get" action="Handler.ashx">  //get方法使提交的表单信息直接诶先  
    9.         <input type="text" name="name" />  
    10.         <button type="submit">嘿嘿嘿嘿</button>  
    11.     </form>  
    12. </body>  
    13. </html>  


    一般处理程序代码:

     

    [plain] view plain copy
     
     print?在CODE上查看代码片派生到我的代码片
    1. <%@ WebHandler Language="C#" Class="Handler" %>  
    2.   
    3. using System;  
    4. using System.Web;  
    5.   
    6. public class Handler : IHttpHandler {  
    7.       
    8.     public void ProcessRequest (HttpContext context) {  ///跳转到一般处理程序的页面就自动运行的方法   
    9.         context.Response.ContentType = "text/html";  
    10.         string res=context.Request["name"];  //获取传递过来的name属性的值;  
    11.         string path = context.Server.MapPath("HtmlPage.html");  //获取网页地址  
    12.         context.Response.Write(System.IO.File.ReadAllText(path));  //读出本地址的内容,然后写出来。  
    13.         context.Response.Write((string.IsNullOrEmpty(res)) ? "你是不是傻,这都不知道" : "哇,你好厉害哟");  
    14.     }  
    15.    
    16.     public bool IsReusable {  
    17.         get {  
    18.             return false;  
    19.         }  
    20.     }  
    21.   
    22. }  

    就是发布一个网页到iis上面,能访问网页的东西,不管你是什么平台,就都能与本机交互了。

    There are two ways of constructing a software design.One is to make it so simple that there are obviously no deficiencies;the other is to make it so complicated that there are no obvious deficiencies.
  • 相关阅读:
    unity工厂模式
    unity对象池
    unity进阶项目------保卫萝卜(2)
    C#状态机
    unity进阶项目------保卫萝卜(1)
    OpenGL——外部读档+异常报错
    OpenGL入门之入门
    xlua build时 报错处理
    捕鱼达人Demo版下载
    UGUI-Text——自适应
  • 原文地址:https://www.cnblogs.com/yuanjunqq/p/5257760.html
Copyright © 2011-2022 走看看