• 一般处理程序


    不同平台之间通信,可以选择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.
  • 相关阅读:
    利用Spring AOP自定义注解解决日志和签名校验
    SpringBoot返回date日期格式化,解决返回为TIMESTAMP时间戳格式或8小时时间差
    @RequestBody配合@JsonFormat注解实现字符串自动转换成Date
    Mysql的时间类型问题
    IntelliJ IDEA使用maven-javadoc-plugin生成Java Doc控制台乱码
    Maven学习笔记(十二)-maven打包之resource配置
    SpringBoot使用@Value从yml文件取值为空--注入静态变量
    cloud server ribbon 自定义策略配置
    JNA 如何 加载多个 存在依赖的 DLL 库
    Remote Desktop File Format
  • 原文地址:https://www.cnblogs.com/yuanjunqq/p/5257760.html
Copyright © 2020-2023  润新知