此Steam不支持超时。该如何解决呢?

时间:2020-07-20 18:07:25

标签: c# asp.net asp.net-mvc-3

 [HttpPost]
        public async Task<ActionResult> AddEditCountry(CountriesViewModel model)
        {
            object token;
            try
            {
                token = Request.Cookies["Token"].Value;
            }
            catch (System.NullReferenceException ex)
            {
                // not logged in or null id.
                return RedirectToAction("Index", "Home");
            }
            client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.ToString());
          
            if (model.Id == Guid.Empty)
            {
                string filename = Path.GetFileNameWithoutExtension(model.imagefile.FileName);
                string extension = Path.GetExtension(model.imagefile.FileName);
                filename = filename + DateTime.Now.ToString("yymmssfff") + extension;
                model.FlagIcon = filename;
                filename = Path.Combine(Server.MapPath("~/uploads/"), filename);
                model.imagefile.SaveAs(filename);

                var postTask = await client.PostAsJsonAsync<CountriesViewModel>(BaseUrl + "Countries/AddCountry", model);
       
                if (postTask.IsSuccessStatusCode)
                {
                    return Json("Contnent Added", JsonRequestBehavior.AllowGet);
                }
                else
                {
                    return Json("Some error occurred. Please try again later", JsonRequestBehavior.AllowGet);
                }
            }
            else
            {
                var postTask = await client.PostAsJsonAsync<CountriesViewModel>(BaseUrl + "Countries/EditCountry?id=" + model.Id, model);

                if (postTask.IsSuccessStatusCode)
                {
                    ViewBag.Success = 1;
                    return RedirectToAction("Index", "Admin");

                }
                else
                {
                    return Json("Some error occurred. Please try again later", JsonRequestBehavior.AllowGet);
                }



            }
        }

我已经使用了很多次此代码,可以正常工作,但是这次我使用图像来保存并调用具有该图像文件名的api来存储在数据库中。但是在将图像保存到代码中之后,当我想要使用模型调用我的Web API,这会导致错误,提示不支持超时。如何解决这个问题?

0 个答案:

没有答案