question

UmarFarooqFazal-6025 avatar image
0 Votes"
UmarFarooqFazal-6025 asked

IFeatures Collection has been disposed, object Name : Collection

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...

azure-ad-user-management
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

0 Answers