title: Unsafe Object Binding in Checkmarx scan
body: <p>I have tried adding <code>null</code> check and try catch blocks but I am not able to solve this issue.</p>
  
  <blockquote>
    <p>Error : 
    The DeleteConfirmed at VCSSource/Web/Controllers/EnvController.cs
    in line 180 may unintentionally allow setting the value of SaveChanges in DeleteConfirmed, in the object
    VCSSource/Web/Controllers/EnvController.cs at line 180</p>
  </blockquote>
  
  <p>Code :</p>
  
  <pre><code>[HttpPost, ActionName("Delete")]
  [ValidateAntiForgeryToken]
  public ActionResult DeleteConfirmed(int id)
   {
       if (id &gt; 0) // fix for CheckMarx : Unsafe Object Binding
          {
             ENV eNV = db.ENVs.Find(id);
             ENV eNV_del = db.ENVs.Remove(eNV);              
              try
                {
                    if (eNV_del != null &amp;&amp; eNV_del.ENV_NM.Length &gt; 0) {
                         db.SaveChanges();
                        }                   
                  return RedirectToAction("Index");
                }
              catch (DataException ex)
                {
                     throw ex;
                }
              }
       else
         {
            return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
         }
     }
  </code></pre>