title: ASP.NET / MVC: No owin.Environment item was found in the context
body: <p>I am doing a ASP.NET MVC web application with VS2013. The machine is Windows Server Enterprise, SP2 and IIS 7.</p>
  
  <p>I got the following error:</p>
  
  <pre><code>Server Error in '/' Application.
  No owin.Environment item was found in the context.
  Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
  
  Exception Details: System.InvalidOperationException: No owin.Environment item was found in the context.
  
  Source Error:
  
  An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
  
  Stack Trace:
  
  [InvalidOperationException: No owin.Environment item was found in the context.]
  </code></pre>
  
  <p>I googled and found a solution and did something like this (by adding  <code>&lt;add name="OWIN".... &gt;</code>) in web.config:</p>
  
  <pre><code>&lt;system.webServer&gt;
      &lt;modules &gt;
          &lt;remove name="FormsAuthenticationModule" /&gt;
          &lt;remove name="UrlRoutingModule-4.0" /&gt;
          &lt;add name="UrlRoutingModule-4.0" type="System.Web.Routing.UrlRoutingModule" preCondition="" /&gt;
      &lt;/modules&gt;  
      &lt;handlers&gt;
          &lt;add name="OWIN" path="*" verb="*" type="Microsoft.Owin.Host.SystemWeb.OwinHttpHandler" /&gt;
      &lt;/handlers&gt;
  &lt;/system.webServer&gt;  
  </code></pre>
  
  <p>After doing this, the web app works. However, all the static files such as CSS and Javascript are not found by the browser (404 on all of them), and so my app is style-less.</p>
  
  <p>What is the correct way of configuring </p>
  
  <pre><code>&lt;handlers&gt;
     &lt;add name="OWIN" path="*" verb="*" type="Microsoft.Owin.Host.SystemWeb.OwinHttpHandler" /&gt;
  &lt;/handlers&gt;
  </code></pre>
  
  <p>to get my app work right? Or I need do something else?</p>
  
  <p>Thanks!</p>