title: Custom providers in ASP.NET MVC
body: <p>Am new at ASP.NET MVC development.</p>
  
  <p>For my <a href="/questions/tagged/asp.net-mvc" class="post-tag" title="show questions tagged &#39;asp.net-mvc&#39;" rel="tag">asp.net-mvc</a> 5 Internet application I have created a custom <a href="/questions/tagged/membership-provider" class="post-tag" title="show questions tagged &#39;membership-provider&#39;" rel="tag">membership-provider</a> as my user-related <a href="/questions/tagged/datatables" class="post-tag" title="show questions tagged &#39;datatables&#39;" rel="tag">datatables</a> in my <a href="/questions/tagged/database" class="post-tag" title="show questions tagged &#39;database&#39;" rel="tag">database</a> contains additional columns which are not supported by the out-of-the-box <a href="/questions/tagged/membership-provider" class="post-tag" title="show questions tagged &#39;membership-provider&#39;" rel="tag">membership-provider</a> provided by ASP.NET (<a href="/questions/tagged/simplemembership" class="post-tag" title="show questions tagged &#39;simplemembership&#39;" rel="tag">simplemembership</a>)</p>
  
  <p>I'm more or less following the implementation method of this blog, <a href="http://www.brianlegg.com/post/2011/05/09/Implementing-your-own-RoleProvider-and-MembershipProvider-in-MVC-3.aspx" rel="nofollow">Implementing your own RoleProvider and MembershipProvider in MVC 3</a> (<em>though I know that I'm working with MVC</em> <strong><em>5</em></strong>).</p>
  
  <p>In the blog at the section titled "Modifying the AccountController to use our new Providers" he inserts the following code in the <code>Initialize</code> method of his <code>AccountController</code></p>
  
  <pre><code>[C#]
  public LocalBankMembershipProvider MembershipService { get; set; }
  public LocalBankRoleProvider AuthorizationService { get; set; }
  
  protected override void Initialize(RequestContext requestContext)
  {
      if (MembershipService == null)
          MembershipService = new LocalBankMembershipProvider();
      if (AuthorizationService == null)
          AuthorizationService = new LocalBankRoleProvider();
  
      base.Initialize(requestContext);
  }
  </code></pre>
  
  <p>The above allows the author of the blog to use his custom membershipprovider's methods in that controller.</p>
  
  <p>If following this bloggers example of how to implement a custom membershipprovider is pretty much the way to go, I was wondering if I have to initialize my custom providers in each and every Controller or does there exist a more elegant way of implementing it in my Controllers?</p>