title: Storing data in WEB API so that it can be used later
body: <p>There is a website for which I am writing web services using C# MVC WEB API so that mobile app could use them for storing and retrieving data. now there is a problem that in one of the methods there is a value that I have to use in another method. I need to access that value. I have read answers of others regarding same issue using session handling but it is also not a good approach. How should I get that value? So far I have done this.</p>
  
  <pre><code>public Object carYears(string Carmade, string CarModel)    //not working
  {
      List&lt;object&gt; list = new List&lt;object&gt;();
      int? manid = Convert.ToInt32(Carmade);
      int? modid = Convert.ToInt32(CarModel);
      var md = db.des_texts.Where(x =&gt; x.TEX_ID == modid).SingleOrDefault();
      var manufac = db.manufacturers.Where(x =&gt; x.MFA_ID == manid).SingleOrDefault();
      var mod = (from modl in db.models
                 join mn in db.manufacturers on modl.MOD_MFA_ID equals mn.MFA_ID
                 join cd in db.country_designations on modl.MOD_CDS_ID equals cd.CDS_ID
                 join dt in db.des_texts on cd.CDS_TEX_ID equals dt.TEX_ID
                 where (mn.MFA_ID == manid) &amp;&amp; (cd.CDS_LNG_ID == 4) &amp;&amp; (modl.MOD_PC == 1) &amp;&amp; (dt.TEX_TEXT == md.TEX_TEXT)
                 orderby mn.MFA_BRAND, dt.TEX_TEXT
                 select new { modl.MOD_ID, mn.MFA_BRAND, dt.TEX_TEXT, modl.MOD_PCON_START, modl.MOD_PCON_END }).FirstOrDefault();
  
      //TempData["modelid"] = mod.MOD_ID;    &lt;-- i need this value in another method
      var session = HttpContext.Current.Session;
      if (session != null)
      {
          if (session["modelid"] == null)
              session["modelid"] = mod.MOD_ID;
  
      }
  </code></pre>
  
  <p>can this TempData be used for this purpose?? One more thing I have made session and stored value in it but still I am unable to access this value in the other method.</p>