title: MVC controller: Common object in methods
body: <p>In my mvc3 controller, a particular object is used in several methods. Should I declare it as a member variable of the controller and provide properties to access that? But what happens with each time one of the action method is called from the client? Will the object be created again and again? Is there any particular advantage for the above mentioned method, if that is the case?
  <strong>Is declaring MySpclClass as singleton class, a good option in this case?</strong> </p>
  
  <p>In short, is there any advantage in using this method: </p>
  
  <pre><code> public class MyController : Controller
      {
           MySpclClass myObject=new MySpclClass();
  
  
          public ActionResult DoFirst(int id)
          {
            ....................
            myObject.doOneThing();
            ....................  
          }
  
          public ActionResult DoSecond(int id)
          {
            ....................
            myObject.doAnotherthing();
            ....................  
          }
      }
  </code></pre>
  
  <p>over this method:</p>
  
  <pre><code>public class MyController : Controller
          {       
  
              public ActionResult DoFirst(int id)
              {
               MySpclClass myObject=new MySpclClass();
                 ....................
                myObject.doOneThing();
                ....................  
              }
  
              public ActionResult DoSecond(int id)
              {
               MySpclClass myObject=new MySpclClass();                            
                ....................
                myObject.doAnotherthing();
                ....................  
              }
  }
  </code></pre>
  
  <p>And what about this:</p>
  
  <pre><code> public class MyController : Controller
              {       
  
                   MySpclClass myObject;
                  public ActionResult DoFirst(int id)
                  {
                   myObject=new MySpclClass();
                     ....................
                    myObject.doOneThing();
                    ....................  
                  }
  
                  public ActionResult DoSecond(int id)
                  {
                   myObject=new MySpclClass();                            
                    ....................
                    myObject.doAnotherthing();
                    ....................  
                  }
      }
  </code></pre>
  
  <p><strong>EDIT:</strong> Is declaring MySpclClass as singleton class, a good option in this case as Rajansoft1 suggested ? Need suggestions on this.</p>