Как ввести CookieCollection в CookieContainer?

  [HttpPost]
    public async Task<ActionResult> Capture(string imageData)
    {                      
        if (imageData.Length > 0)
        {
            var imageBytes = Convert.FromBase64String(imageData);
            using (var stream = new MemoryStream(imageBytes))
            {
                var result = (JsonResult)await IdentifyFace(stream);
                var serializer = new JavaScriptSerializer();
                var faceRecon = serializer.Deserialize<FaceIdentity>(serializer.Serialize(result.Data));

                if (faceRecon.Success) return RedirectToAction("Index", "Auth", new { param = serializer.Serialize(result.Data) });

            }
        }

        return Json(new { success = false, responseText = "Der opstod en fejl - Intet billede, manglede data." }, JsonRequestBehavior.AllowGet);

    }


// GET: Auth
    [HttpGet]
    public ActionResult Index(string param)
    {
        var serializer = new JavaScriptSerializer();
        var faceRecon = serializer.Deserialize<FaceIdentity>(param);


        return View(faceRecon);
    }
17
задан Skuta 13 February 2009 в 15:56
поделиться

3 ответа

request.CookieContainer = new CookieContainer();
request.CookieContainer.Add(response.Cookies);

По данным Microsoft:

CookieContainer является нулевой ссылкой (Ничто в Visual Basic) по умолчанию. Необходимо присвоить объект CookieContainer свойству, чтобы возвратить cookie в свойстве Cookies HttpWebResponse, возвращенного методом GetResponse.

32
ответ дан 30 November 2019 в 12:08
поделиться
request.CookieContainer.Add(response.Cookies);
2
ответ дан 30 November 2019 в 12:08
поделиться
dim cookie as new cookiecontainer

//request codes here
//response here

cookie.add(response.cookies)
0
ответ дан 30 November 2019 в 12:08
поделиться
Другие вопросы по тегам:

Похожие вопросы: