Unable to read data from the transport connection: An existing connection was forcibly closed by the
Hi,I am getting following error how to solve the problem.
Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.
MY code
try
{
values.Add("apikey", ConfigurationManager.AppSettings["apikey"]);
values.Add("username", _model.Email);
values.Add("password", _model.Password);
var content = new FormUrlEncodedContent(values);
//Byte[] byteArray = content.ReadAsByteArrayAsync().Result;
//System.Text.UTF8Encoding enc = new System.Text.UTF8Encoding();
//string str = enc.GetString(byteArray);
var httpResponseMessage = client.PostAsync(ApiBaseURL + "security/userlogin/", content).Result;
if (httpResponseMessage.StatusCode == HttpStatusCode.OK)
{
// Do something...
var json = httpResponseMessage.Content.ReadAsStringAsync().Result;
account = JsonConvert.DeserializeObject<RootObject>(json.ToString());
}
if (account.status_code != 0)
{
Session["orgid"] = account.user.profile.orgid;
Session["ArtistName"] = account.user.profile.organizationname;
Session["screenname"] = account.user.profile.screenname;
Session["ArtistEmail"] = account.user.profile.contactemail; // Add the value once you receive it from the service
Session["DropkickUID"] = account.user.profile.dropkickuid;
if (account.status_code == 1)
{
ViewBag.Invalid = "";
return RedirectToAction("SelectTitle", "SelectTitle");
}
else
{
ModelState.AddModelError("", "Invalid username and/or password");
ViewBag.Invalid = "Invalid username and/or password";
}
}
else
{
ModelState.AddModelError("", "Invalid username and/or password");
ViewBag.Invalid = "Invalid username and/or password";
}
}
catch (Exception ex)
{
string refUrl = "";
if (Request.UrlReferrer != null)
refUrl = Request.UrlReferrer.ToString();
Erromessage = ex.Message.ToString();
}
return View(_model);