title: NserviceBus Hosted in IIS issue
body: <p>I've been working on a project where I need Nservicebus to be hosted in IIS.
  I need the MVC3 webapplication to send a message, a nservicebus host should handle this message
  and then send back some sort of message to the webapplication.</p>
  
  <p>the Async Pages example <a href="http://docs.particular.net/samples/web/asp-mvc-application/" rel="nofollow">http://docs.particular.net/samples/web/asp-mvc-application/</a>
  shows one way of doing it. I can get this to work, however this does not fully furfill my requirements. I need an object to be returned from the handler, not just an int.</p>
  
  <p>To get this to work i've tried setting up a host under IIS, in my Global.asax I've got this code:</p>
  
  <pre><code>Bus = Configure.WithWeb()                
                 .DefineEndpointName("CQRS")
                 .Log4Net()                   
                 .DefaultBuilder()                
                 .DisableTimeoutManager()                
                 .XmlSerializer()
                 .MsmqTransport()
                     .IsTransactional(true)
                     .PurgeOnStartup(false)
                     .InMemorySubscriptionStorage()
                 .UnicastBus()              
                     .AllowSubscribeToSelf()
                     .ImpersonateSender(false)
                     .LoadMessageHandlers()  
                     .CreateBus().Start();  
  </code></pre>
  
  <p>my web.config:</p>
  
  <pre><code>&lt;MessageForwardingInCaseOfFaultConfig ErrorQueue="CQRS.error" /&gt;
   &lt;MsmqTransportConfig NumberOfWorkerThreads="1" MaxRetries="5"  /&gt;
  
   &lt;UnicastBusConfig  DistributorControlAddress="" DistributorDataAddress="" TimeoutManagerAddress="CQRS.timeouts"&gt;
    &lt;MessageEndpointMappings&gt;
       &lt;add Messages="Nokavision.InvoiceProcessing.CQRS.Messages" Endpoint="CQRS" /&gt;
       &lt;add Messages="NServiceBus.Scheduling.Messages.ScheduledTask" Endpoint="CQRS" /&gt;      
    &lt;/MessageEndpointMappings&gt;
  &lt;/UnicastBusConfig&gt;
  </code></pre>
  
  <p>Sending messages with the Bus object works perfectly, a message appears in the "cqrs" queue.
  The handler within the webapplication however does not trigger. This is the code:</p>
  
  <pre><code>public class UpdateInkoopFactuurAlgemeenHandler : IHandleMessages&lt;UpdateInkoopFactuurAlgemeenCommand&gt;
  {
      public IBus Bus { get; set; }
  
      public void Handle(UpdateInkoopFactuurAlgemeenCommand message)
      {
          P2PEntities entities = new P2PEntities();
  
          var factuur = (from f in entities.Documenten.OfType&lt;InkoopFactuur&gt;()
                         where f.DocumentId == message.DTO.DocumentId
                         select f).FirstOrDefault();
  
          if (factuur != null)
          {
              factuur.FactuurNummer = message.DTO.FactuurNummer;
              entities.SaveChanges();
          }
  
          //Bus.Return(new UpdateInkoopFactuurAlgemeenResponse(message.DTO.ClientConnectionId));
  
      }
  }
  </code></pre>
  
  <p>I'm sure I'm missing something small here but what am I doing wrong, why doesn't the handler get triggered while I can clearly see a message in the queue.
  Also on the Bus object I can see the handler being loaded.</p>