title: IFeatureCollection has been disposed. Object name: 'Collection'. going from controller to view
body: <p>I am new to all of this, and am in the early stages of making this web application. This is just for my personal use. I am trying to display the results of a web api call in a view. The api call works fine. I can see the data coming back from services and being placed in the DTO fine. It goes from the services to the controller but I am not sure why every time I try to send data from the controller to the view I get the same exception:</p>
  <blockquote>
  <p>IFeatureCollection has been disposed. Object name: 'Collection'.</p>
  </blockquote>
  <p>Can anyone tell me what does it mean and how do I fix the issue?</p>
  <p>Here is my Startup.cs</p>
  <pre class="lang-cs prettyprint-override"><code>
  public Startup(IConfiguration configuration)
  {
      Configuration = configuration;
  }
  
  public IConfiguration Configuration { get; }
  
  // This method gets called by the runtime. Use this method to add services to the container.
  public void ConfigureServices(IServiceCollection services)
  {
      services.AddHttpClient(&quot;mapQUrl&quot;, client =&gt; { client.BaseAddress = new Uri(&quot;https://www.mapquestapi.com/geocoding/v1/address?&quot;); });
      services.AddHttpClient(&quot;climaUrl&quot;, client =&gt; { client.BaseAddress = new Uri(&quot;https://api.climacell.co/v3/weather/nowcast?&quot;); });
      services.AddControllersWithViews();
      services.AddScoped&lt;IServices, Services&gt;();
  
  }
  
  // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
  public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
  {
      if (env.IsDevelopment())
      {
          app.UseDeveloperExceptionPage();
      }
      else
      {
          app.UseExceptionHandler(&quot;/Home/Error&quot;);
          // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
          app.UseHsts();
      }
      app.UseHttpsRedirection();
      app.UseStaticFiles();
  
      app.UseRouting();
  
      app.UseAuthorization();
  
      app.UseEndpoints(endpoints =&gt;
      {
          endpoints.MapControllerRoute(
              name: &quot;default&quot;,
              pattern: &quot;{controller=Home}/{action=Index}/{id?}&quot;);
      });
  }
  </code></pre>
  <p>This is my services:</p>
  <pre class="lang-cs prettyprint-override"><code>public async Task&lt;List&lt;ClimaCellDto&gt;&gt; GetTemp(MapQuestFlatDto loc)
  {
      List&lt;ClimaCellDto&gt; dataObjects = new List&lt;ClimaCellDto&gt;();
      
      var client = _clientFactory.CreateClient(&quot;climaUrl&quot;);
      string attr = &quot;unit_system=us&amp;timestep=5&amp;start_time=now&amp;fields=temp&amp;&quot;;
      var url = client.BaseAddress + attr + climaUrlParameters;
  
      // Add an Accept header for JSON format.
      client.DefaultRequestHeaders.Accept.Add(
      new MediaTypeWithQualityHeaderValue(&quot;application/json&quot;));
  
      HttpResponseMessage response = await client.GetAsync(url);  // Blocking call! Program will wait here until a response is received or a timeout occurs.
      if (response.IsSuccessStatusCode)
      {
          // Parse the response body.
          var strContent = await response.Content.ReadAsStringAsync();  //Make sure to add a reference to System.Net.Http.Formatting.dll
  
          dataObjects = JsonConvert.DeserializeObject&lt;List&lt;ClimaCellDto&gt;&gt;(strContent);
          return dataObjects;
      }
      else
      {
          Console.WriteLine(&quot;{0} ({1})&quot;, (int)response.StatusCode, response.ReasonPhrase);
      }
  
      return dataObjects;
  }
  </code></pre>
  <p>This is the controller method that is receiving the data from the service and sending it to the view:</p>
  <pre class="lang-cs prettyprint-override"><code>[HttpPost]
  public async void getLoc ([FromBody]ZipDto obj)
  {    
      var zip = Int32.Parse(obj.zip);
      var location = await _services.GetLatLng(zip);
      var climate =  await _services.GetTemp(location);
      ShowResults(climate);
  }
  
  public IActionResult ShowResults(List&lt;ClimaCellDto&gt; data)
  {
      try
      {
          return View(data);
      }
      catch (Exception ex)
      {
          throw ex;
      }
  }
  </code></pre>
  <p>and this is the view:</p>
  <pre><code>    @model IEnumerable&lt;Weather_web_app.DTOs.ClimaCellDto&gt;
  
  @{
      ViewData[&quot;Title&quot;] = &quot;ShowResults&quot;;
  }
  
  &lt;h1&gt;ShowResults&lt;/h1&gt;
  
  &lt;p&gt;
      &lt;a asp-action=&quot;Create&quot;&gt;Create New&lt;/a&gt;
  &lt;/p&gt;
  &lt;table class=&quot;table&quot;&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;
                  @Html.DisplayNameFor(model =&gt; model.lat)
              &lt;/th&gt;
              &lt;th&gt;
                  @Html.DisplayNameFor(model =&gt; model.lon)
              &lt;/th&gt;
              &lt;th&gt;&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
  @foreach (var item in Model) {
          &lt;tr&gt;
              &lt;td&gt;
                  @Html.DisplayFor(modelItem =&gt; item.observation_time.value)
              &lt;/td&gt;
              &lt;td&gt;
                  @Html.DisplayFor(modelItem =&gt; item.temp.value)
              &lt;/td&gt;
          &lt;/tr&gt;
  }
      &lt;/tbody&gt;
  &lt;/table&gt;
  </code></pre>
  <p>This is the call stack:</p>
  <pre><code>at Microsoft.AspNetCore.Http.Features.FeatureReferences`1.ThrowContextDisposed()
      at Microsoft.AspNetCore.Http.Features.FeatureReferences`1.ContextDisposed()
      at Microsoft.AspNetCore.Http.Features.FeatureReferences`1.Fetch[TFeature,TState](TFeature&amp; cached, TState state, Func`2 factory)
      at Microsoft.AspNetCore.Http.DefaultHttpContext.get_RequestServices()
      at Microsoft.AspNetCore.Mvc.Controller.get_TempData()
      at Microsoft.AspNetCore.Mvc.Controller.View(String viewName, Object model)
      at Microsoft.AspNetCore.Mvc.Controller.View(Object model)
  </code></pre>
  <p>I have looked online for hours for someone having a similar issue but I have not found anything. Any help is greatly appreciated. Thanks in advance.</p>