Access post data directly

前端 未结 6 815
时光说笑
时光说笑 2020-12-15 02:45

I have an action in one of my controllers that is going to receive HTTP POST requests from outside of my MVC website.

All these POST requests will have the same par

6条回答
  •  旧巷少年郎
    2020-12-15 03:11

    Stream req = Request.InputStream;
                req.Seek(0, System.IO.SeekOrigin.Begin);
                string json = new StreamReader(req).ReadToEnd();
    
                JavaScriptSerializer serializer = new JavaScriptSerializer();
                dynamic items = serializer.Deserialize(json);
                string id = items["id"];
                string image = items["image"];
    
    
    

    ///you can access paramters by name or index

    提交回复
    热议问题