title: HttpPostedFileBase's relationship to HttpPostedFileWrapper
body: <p>I understand the relationship between <code>HttpPostedFileBase</code> and <code>HttpPostedFileWrapper</code>, in terms of the need for both of them (i.e. in unit testing/mocking).  But why, when I put a breakpoint on the return for <code>HttpPostedFileBase</code>, does it show it as <code>HttpPostedFileWrapper</code>?</p>
  
  <p>Furthermore, <code>HttpPostedFileBase</code> doesn't implement the ContentType property. So why does it return a value when my code <em>only</em> references <code>HttpPostedFileBase</code>, and not <code>HttpPostedFileWrapper</code>?  What kind of trickery is this?</p>
  
  <p><img src="https://i.stack.imgur.com/k0MEp.png" alt="enter image description here"></p>
  
  <p><strong>Edit #1:</strong> </p>
  
  <p>Thanks for the great reply @lawliet29.  I have written out the structure as suggested.</p>
  
  <pre><code>public sealed class MyHttpPostedFile
  {
      public string ContentType { get { return "123"; } }
  }
  
  public abstract class MyHttpPostedFileBase
  {
  }
  
  public class MyHttpPostedFileWrapper : MyHttpPostedFileBase
  {
      private MyHttpPostedFile _myHttpPostedFile;    
  
      public MyHttpPostedFileWrapper(MyHttpPostedFile myHttpPostedFile) { 
          _myHttpPostedFile = myHttpPostedFile;
      }
  
      public string ContentType { get { return _myHttpPostedFile.ContentType; } }
  }
  </code></pre>
  
  <p>In order for this to work though, I would need to pass the parameter like this:</p>
  
  <pre><code>GetFiles(new MyHttpPostedFileWrapper(new MyHttpPostedFile());
  </code></pre>
  
  <p>This seems to be where the trickery I am questioning exists. How does .NET know that the bytes being passed to it is a class of type <code>MyHttpPostedFile</code> and that it should take that object and pass it into my constructor's as a parameter?</p>
  
  <p><strong>Edit #2:</strong></p>
  
  <p>I didn't realise the ASP.NET MVC binder would do more than just pass bytes by passing these higher level objects. This is the trickery I was wondering about! Thanks for the great responses.</p>