在asp.net上多次响应POST请求

时间:2019-04-07 19:42:49

标签: javascript c#

我有一个标头为'keep-alive'的POST请求,我希望我的服务器能够多次对此写响应。

因此,我有一个UserConnection表,其中包含所有POST响应,以写入所有已连接用户的响应流。当我写响应流时,另一端什么也没出来。


    if (req.funct == "setChat") {
        foreach (UserConnections con in Global.Connections) {
            con.connection.Write(user.UserName + " : " + req.data);
        }
    } else if (req.funct == "connect") {
       bool found = false;
       foreach(UserConnections cur in Global.Connections) {
          if (cur.User.UserId == user.UserId) {
             found = true;
             cur.lastUsed = DateTime.Now;
          }
       }
       if (!found) {
          Global.Connections.Add(new UserConnections() {
             User = user,
             connection = Response,
             lastUsed = DateTime.Now
       });
    }


    function httpPost(funct, projectID, Data) {
        $.post("http://localhost:59343/webhooks/post.aspx", funct + "\n" + projectID + "\n" + getCookie("Account") + "\n" + Data, function (data, status) {
            document.getElementById("Chat").innerHTML = document.getElementById("Chat").innerHTML + "<option value=\"" + data + "\">" + data + "</option>";
            console.log(status + "\n" + data);
        });
    }

它应该使用消息的内容创建一个新的<option></option>,但是数据为空。 The output of the console after doing the request

0 个答案:

没有答案