title: Should I register a per request concrete class using a lambda with Autofac?
body: <p>I am new to Autofac and am researching different best practices.  Per this <a href="http://docs.autofac.org/en/latest/best-practices/#register-frequently-used-components-with-lambdas" rel="nofollow">Best Practices and Recommendations</a> document, it is recommended that frequently used components should be registered using lambdas.</p>
  
  <p>I have a concrete class, <code>CurrentUser</code> that implements <code>IUserIdentity</code>.  This concrete class takes in <code>HttpContextBase</code> in order to retrieve the user's identity (id, roles, etc).  My services obviously depend upon <code>IUserIdentity</code>.</p>
  
  <p>I am <em>currently</em> registering this like this:</p>
  
  <p><code>builder.RegisterType&lt;CurrentUser&gt;().As&lt;IUserIdentity&gt;().InstancePerRequest()</code></p>
  
  <p>After reading this article, I am wondering if I should register it using a lambda since this will get resolved <em>many</em> times?</p>
  
  <p>If so, how do I provide <code>HttpContextBase</code> since in my current code Autofac resolves it for me.</p>