title: IIS Windows Authentication does not work with Webmatrix / Razor CSHTML
body: <p>I need to use IIS Windows Authentication instead of Anonymous so that I can get the visitors username. The server and all the pages are on a local domain and all visitors are logged into the domain. The problem I am having is that Windows Authentication does not work with Webmatrix pages.</p>
  
  <p>On IIS we just have one site and there are various pages and sections. Some are ASPX and now we also started creating CSHTML with Webmatrix/Razor. When enabling Windows Authentication and disabling Anonymous, any page that you try to load (ASPX, CSHTML, etc...) automatically redirects to <strong>/Account/Login?ReturnUrl=</strong> which does not exist and results in a 404 error.</p>
  
  <p>I don't know why this happens. 
  Windows Authentication worked fine before the Webmatrix files were added.
  I have tried numerous suggestions and nothing has resolved the issue.</p>
  
  <p>I found several posts online saying that there maybe a bug in Webmatrix and that the <strong>WebMatrix.Data.dll and WebMatrix.WebData.dll</strong> are causing the issue. So just as a test I deleted these files from the Bin folder and right away the ASPX files started to load fine and authentication worked OK. Problem is that without these DLL's none of the CSHTML pages work which is what we really need.</p>
  
  <p>Is there a fix for this? Removing the DLL's I mentioned is not an option for us since it breaks the most import functions which is querying and displaying data from SQL but at the same time I really need Windows Authentication to work with Webmatrix and CSHTML because we need to know who is using the pages and its impossible when IIS is running in Anonymous mode.</p>