1
13693261870
2022-09-16 762f2fb45db004618ba099aa3c0bd89dba1eb843
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<%@ WebHandler Language="C#" Class="Handler" %>
 
using System;
using System.Web;
using System.IO;
 
public class Handler : IHttpHandler {
    
    public void ProcessRequest (HttpContext context) 
    {
        string action = HttpContext.Current.Request["action"];
        if (action == "GetData")
        {
            GetData(context);
        }
        else if (action == "SaveData")
        {
            SaveData(context);
        }
        else if (action == "SaveLayerData")
        {
            SaveLayerData(context);
        }
    }
 
    private void GetData(HttpContext context)
    {
        string strJson = "";
        string name = context.Request["Name"];
        string age = context.Request["Age"];
        strJson = "姓名:" + name + ",年龄:" + age;
        context.Response.Charset = "UTF-8";
        context.Response.Write(strJson);
        context.Response.End();
    }
 
    private void SaveData(HttpContext context)
    {
        string name = HttpContext.Current.Server.UrlDecode(context.Request["Name"]);
        string txtPath = HttpContext.Current.Server.MapPath("./") + "bookmarks.json"; //MapPath("./")表示当前目录
        StreamWriter sw = new StreamWriter(txtPath, false, System.Text.Encoding.UTF8);
        sw.WriteLine(name);
        sw.Close();
    }
 
    private void SaveLayerData(HttpContext context)
    {
        string name = HttpContext.Current.Server.UrlDecode(context.Request["Name"]);
        string txtPath = HttpContext.Current.Server.MapPath("./") + "plotLayer.json";
        StreamWriter sw = new StreamWriter(txtPath, false, System.Text.Encoding.UTF8);
        sw.WriteLine(name);
        sw.Close();
    }
 
    public bool IsReusable {
        get {
            return false;
        }
    }
 
}