在调用json结果后,一个长循环崩溃我的webapp

时间:2017-09-14 19:41:32

标签: c# asp.net json model-view-controller asp.net-ajax

我遇到了一个问题:我正在通过网络服务并在数据库中保存数据。

我的代码有效,但问题是我在布局chrome上从ajax调用它崩溃了。

控制器:

.Rmd

和我的ajax调用布局:

 [HttpPost]
        public JsonResult seen()
        {
            var us = User.Identity.Name;
            var loginuserID = db.workers.Where(r => r.UserId == us).FirstOrDefault();
            var Ids = db.Clients.Select(r => r.login).ToList();

            List<apicli> list1 = new List<apicli>();
            List<notification> notifications = new List<notification>();
            var notificat = new notification();
            var clie = new apicli();
            var sales1 = new sales();
            List<sales> sales = new List<sales>();

            foreach (var item1 in Ids)
            {
                var client = new WebClient();
                var text = client.DownloadString("http://website.com/api-v2/mt4_prices.php?mode=mt4_trades&s="+item1+"&name=username&pass=password");
                var wclients = JsonConvert.DeserializeObject<dynamic>(text);
                var data = wclients;
                var deposit = wclients;
                if (!db.sales.Any(a => a.Ticket == sales1.Ticket && a.CMD == sales1.CMD))

                {
                    if (sales1.CMD == 6)
                    {
                        notifications.Add(notificat);
                        db.SaveChanges();
                    }

                }

            }



            return new JsonResult();
        }

0 个答案:

没有答案