title: File upload fails when user is authenticated. Using IIS7 Integrated mode
body: <p>These are the user identities my website tells me that it uses:  </p>
  
  <p>Logged on: <strong>NT AUTHORITY\NETWORK SERVICE</strong> (Can not write any files at all)<br>
  and<br>
  Not logged on: <strong>WSW32\IUSR_77</strong> (Can write files to any folder)  </p>
  
  <p>I have a ASP.NET 4.0 website on a shared hosting IIS7 web server running in Integrated mode with 32-bit applications support enabled and MSSQL 2008. Using classic mode is not an option since I need to secure some static files and I use Routing.</p>
  
  <p>In my web.config file I have set the following:  </p>
  
  <pre><code>&lt;system.webServer&gt;
      &lt;modules runAllManagedModulesForAllRequests="true" /&gt;
  &lt;/system.webServer&gt;
  </code></pre>
  
  <p>My hosting company says that Impersonation is enabled by default on machine level, so this is not something I can change.</p>
  
  <p>I asked their support and they referred me to this article: <a href="http://www.codinghub.net/2010/08/differences-between-integrated-mode-and.html" rel="nofollow">http://www.codinghub.net/2010/08/differences-between-integrated-mode-and.html</a></p>
  
  <p>Citing this part:  </p>
  
  <blockquote>
    <p>Different windows identity in Forms
    authentication</p>
    
    <p>When Forms Authentication is used by
    an application and anonymous access is
    allowed, the Integrated mode identity
    differs from the Classic mode identity
    in the following ways:</p>
  
  <pre><code>* ServerVariables["LOGON_USER"] is filled.
  * Request.LogognUserIdentity uses the credentials of the [NT AUTHORITY\NETWORK SERVICE] account instead of the [NT AUTHORITY\INTERNET USER] account. 
  </code></pre>
    
    <p>This behavior occurs because
    authentication is performed in a
    single stage in Integrated mode.
    Conversely, in Classic mode,
    authentication occurs first with IIS
    7.0 using anonymous access, and then with ASP.NET using Forms
    authentication. Thus, the result of
    the authentication is always a single
    user-- the Forms authentication user.
    AUTH_USER/LOGON_USER returns this same
    user because the Forms authentication
    user credentials are synchronized
    between IIS 7.0 and ASP.NET.</p>
    
    <p>A side effect is that LOGON_USER,
    HttpRequest.LogonUserIdentity, and
    impersonation no longer can access the
    Anonymous user credentials that IIS
    7.0 would have authenticated by using Classic mode.</p>
  </blockquote>
  
  <p>How do I set up my website so that it can use the proper identity with the proper permissions? </p>
  
  <p>I've looked high and low for any answers regarding this specific problem, but found nil so far...</p>
  
  <p>I hope you can help!</p>
  
  <p>[<strong>Bump</strong>]</p>