title: The ObjectContext instance has been disposed and can no longer be used for operations that require a connection error cascade dropdown list
body: <p>i try to cascade dropdownlist in MVC4.
  i have 2 dropdown list 1 - Category
  2 - SubCategory. </p>
  
  <p>When the user create new product he need to choose Category and then a SubCategory that related to the category. 
  i use ajax with jason . </p>
  
  <pre><code> public ActionResult Create()
      {
  
          List&lt;Category&gt; allcategories = new List&lt;Category&gt;();
          List&lt;SubCategory&gt; allSubCategories = new List&lt;SubCategory&gt;();
  
          using (WebStoreEntities1 db1 = new WebStoreEntities1())
          {
              allcategories = db1.Categories.OrderBy(x =&gt; x.CategoryName).ToList();
          }
  
          ViewBag.categoryID = new SelectList(db.Categories, "CategoryId", "CategoryName");
          ViewBag.SubCategoryID = new SelectList(allSubCategories, "SubCategoryId",    "SubCategoryName");
  
          return View(main);
      }
  </code></pre>
  
  <p>in the html page the Jquery code:</p>
  
  <pre><code>    $(document).ready(function () {
  
          var $SubCategoryID = $('#SubCategoryID');
  
          $('#CategoryID').change(function () {
  
              var CategoryID = $('#categoryID').val();
  
              if (!isNaN(CategoryID)) {
                  var ddCategory = $("#SubCategoryID");
                  ddCategory.empty();
                  ddCategory.append($("&lt;option&gt;&lt;/option&gt;").val("").html("Sub Category!"));
                  $.ajax({
                      type: 'GET',
                      url: '@Url.Action("GetSubCategories", "StoreManager")',
                      data: { CategoryID: CategoryID },
                      //dataType: "json",
                      success: function (data) {
                          console.log('success',data)//for test 
                          $.each(data, function (i, val) {
                              ddCategory.append(
                              //$SubCategoryID.append(
                                  $('&lt;option&gt;&lt;/option&gt;').val(val.SubCategoryId).html(val.SubCategoryName)
                                  );
                          });
                      },
                      error: function () {
                          alert("Error");
                      }
                  });
              }
          });
      });
  </code></pre>
  
  <p>and the code handels this request is: </p>
  
  <pre><code>[HttpGet]
      public JsonResult GetSubCategories(string categoryID )
      {
          List&lt;CategoryToSubCategory&gt; allSubCategory = new List&lt;CategoryToSubCategory&gt;();
          int id = 0;
          if (int.TryParse(categoryID,out id))
          {
              using(WebStoreEntities1 db1 = new WebStoreEntities1())
              {
                  allSubCategory = db1.CategoryToSubCategories.Where(a =&gt; a.CategoryId.Equals(id)).OrderBy(a =&gt; a.SubCategory.SubCategoryName).ToList();
              }
          }
          if (Request.IsAjaxRequest())
          {
              return new JsonResult
              {
                  Data=allSubCategory,
                  JsonRequestBehavior=JsonRequestBehavior.AllowGet
              };
          }
          else
          {
              return new JsonResult
              {
                  Data="error"
              };
          }
  
      }
  </code></pre>
  
  <p>The CategoryToSubCategory Model:</p>
  
  <pre><code>public partial class CategoryToSubCategory
  {
      public int CategoryToSubId { get; set; }
      public int CategoryId { get; set; }
      public int SubCategoryId { get; set; }
      public Nullable&lt;int&gt; ProductId { get; set; }
  
      public virtual Product Product { get; set; }
      public virtual SubCategory SubCategory { get; set; }
  }
  </code></pre>
  
  <p>all work but in the html insted to get the category name i get an erorr and in the console i see this error: 500 server error:
  The ObjectContext instance has been disposed and can no longer be used for operations that require a connection.</p>
  
  <p>What I need to do ? </p>