IFeatures Collection has been disposed, object Name : Collection

Umar Farooq Fazal 1 Reputation point
2021-08-25T10:05:49.14+00:00

Hi Dear All,

i have created a web api project and created a new web api named login, now i created asp.net core web application and make a login view and i am access web api method with HttpClient class, everything is ok but when i try to call

RedirectToAction() Method, it give me error "IFeatures Collection has been disposed, object Name : Collection" but when i comment all web api call code then this exception is not generated

Sample Code

[AllowAnonymous]
[HttpPost]
public async void VerifyUser(UsersEL objUser)
{
UsersEL oelUserResult = null;
string JsonParam = JsonConvert.SerializeObject(objUser);
var httpClient = new HttpClient();

        httpClient.DefaultRequestHeaders.Accept.Add(
        new MediaTypeWithQualityHeaderValue("application/json"));
        //var content = new StringContent(JsonConvert.SerializeObject(objUser), Encoding.UTF8, "application/json");
        //var response = await httpClient.GetAsync("https://localhost:44310/api/Login?Jsontest=" + JsonParam);
        var response = await httpClient.GetAsync("https://localhost:44310/api/Login");
        string apiResponse = await response.Content.ReadAsStringAsync();
        //reservationList = JsonConvert.DeserializeObject<List<Reservation>>(apiResponse);
        oelUserResult = JsonConvert.DeserializeObject<UsersEL>(apiResponse);




        if (oelUserResult.IdProject.HasValue)
            RedirectToAction("Index", "MainApp");
        else
            RedirectToAction("Index", "MainApp");

    }

Waiting Reponse please

kindly help...

Microsoft Entra ID
Microsoft Entra ID
A Microsoft Entra identity service that provides identity management and access control capabilities. Replaces Azure Active Directory.
22,115 questions
0 comments No comments
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.