title: Dependency Injection and use of default constructor
body: <p>I am trying to understand Dependency Injection concept.
  Below is the  example I am trying  to debug.
  Here I have created Customer class whose dependencies I have Injected  in his constructor 
  Now when  i called <code>this.Iorder.GetOrderDetails();</code> in the <code>Index</code> method it is giving me error of <code>NullReferenceException</code> and asking to use <code>new</code> keyword to create an object to call the method. 
  When  I moved this call <code>this.Iorder.GetOrderDetails();</code> to another method <code>GetCutomerDetails()</code> and call that method  in  Index Method  it works.</p>
  
  <p><strong>Question</strong>: I am not able to understand why <code>this.Iorder.GetOrderDetails()</code>  method call is not working in  <code>Index</code> method and  why it is working  in <code>GetCutomerDetails()</code></p>
  
  <pre><code>public  interface IorderDetails
  {
      void GetOrderDetails();
  }
  
  public class CustomerModel : IorderDetails
  {
      public void GetOrderDetails() {}
  }
  </code></pre>
  
  <p>Controller:</p>
  
  <pre><code>public class CustomerController: Controller
  {
      private IorderDetails Iorder;
  
      //DI constructor  Injecting OrderDetails object 
      CustomerController(IorderDetails iorderObj)
      {
          if (iorderObj == null)
              throw new ArgumentNullException("orderObj should not be null");
  
          this.Iorder = iorderObj;
      }
      //Default constructor  
      public CustomerController() { }
  
      public ActionResult Index()
      {            
         CustomerController objCustomer = new CustomerController(new CustomerModel());
         objCustomer.GetCutomerDetails();
  
         //Commented GetOrderDetails() method
         //this.Iorder.GetOrderDetails();            
         return View();
      }
  
      public ActionResult GetCutomerDetails()
      {
          this.Iorder.GetOrderDetails();
          return View();
      }
  }
  </code></pre>