Rick Strahl's Web Log

Wind, waves, code and everything in between...
ASP.NET • C# • HTML5 • JavaScript • AngularJs
Contact   •   Articles   •   Products   •   Support   •   Search
Ad-free experience sponsored by:
ASPOSE - the market leader of .NET and Java APIs for file formats – natively work with DOCX, XLSX, PPT, PDF, images and more

Mysteriously stubborn IIS 401.2 Errors

I just had one of those wonderful days where everything in Windows just falls apart. I set out yesterday morning to finally install ASP.NET 5 Beta 8. One of the installs along the way is the Visual Studio Web Tools Update for Beta 8. Ok, so I installed that and towards the end of that install the machine blue screens with a REGISTRY_ERROR.

Ok, so after the reboot I tried again - same bloody thing: Full Windows Blue screen. Aaargh.

So I figured I'll check in Visual Studio and sure enough it appears the install actually worked. I can see the Beta 8 tools installed in the VS About screen. Except - it really isn't all there. Visual Studio started throwing all sorts of package load errors. Hrrmph. I knew what was coming next - uninstalling and reinstalling Visual Studio.

Except - that Visual Studio would now not uninstall. It'd start uninstalling and then just hang half way through the uninstall would hang. Lovely. So then came a long string of Repair, Uninstall, Reinstall - all yielding slightly different and equally unsatisfactory results. I was eventually able to uninstall and reinstall Visual Studio, but still have major packages failing to install. I still don't have a stable Visual Studio 2015 install at this point.

But it gets worse.

IIS Configuration Corruption

I also started having major issues with IIS. IIS now would run static content just fine but all ASP.NET content would either throw an auth dialog or show with a nice fat 401.2 error page when only Anonymous access was enabled:


Aargh. Nothing I initially tried - checking disk permissions, using different anonymous accounts, disabling security entirely with mode=none - would work. 

Corrupted and/or Missing master web.config File

After a bit of sleuthing I found that the .NET master web.config file got completed corrupted - containing binary data. No wonder things were not working. I copied out a new web.config from web.config.default in the .NET framework folders and thought that would fix it. Except it didn't.

Even though I had copied in a new web.config, after going back and checking I could see that the web.config had disappeared again. And that missing web.config file was the culprit all along: After hours of poking around in the IIS settings (and I consider myself rather adept at knowing IIS settings like the back of my hand) I finally found when I looked at the .NET Trust levels at the Machine root,  the .NET Trust Levels were missing:


which was the dead givaway that something was very wrong. The fix in my case was to copy the web.config.default to web.config and voila everything snapped back to working.

These values are defined in the .NET master configuration web.config file which lives in:



Not surprisingly the 32 bit file was the one that had been corrupted previously and caused the initial havoc I had seen. Oddly the web.config in these folders simply were not there. Gone, missing and with it the base ASP.NET configuration which caused all sorts of problems. Once I replaced those with the default files, things started working the way they should.

A Reinstall Didn't Fix it!

But here's the real WTF: Prior to this discovery I had completely uninstalled IIS and renamed the windows\system32\INETSVR folder to force IIS to reinstall itself from scratch as it did. It created a new inetsvr folder but it did not install web.config files in the above config folders. Even after a full uninstall/reinstall I still saw the same failure of a continues login dialog or a 401.2 error. WTF???

I still had to manually copy the web.config.default to web.config in order for those settings to get picked up. For a sanity check I went over to my live Web Server and double checked and sure enough there's a web.config file in the Framework\Config folder. But on this machine even a complete reinstall didn't create one for me.

That's now solved my IIS problem. I still don't have a working copy of Visual Studio, but I'll leave that for another post once I figure out what the heck the problem is with that.

I'll be at DevIntersection in Vegas this fall giving sessions on ASP.NET Core with Angular and Localization. Thinking of coming? Use discount code STRAHL and save a few bucks. If you do be sure to stop by and say hello!

ASP.NET DevIntersection 2017. Rick Strahl Coupon Code

Posted in IIS7   ASP.NET  

The Voices of Reason


October 29, 2015

# re: Mysteriously stubborn IIS 401.2 Errors

So, have you figured out what could've corrupted web.config?

Lex Li
October 30, 2015

# re: Mysteriously stubborn IIS 401.2 Errors

Thanks. That reminds always how lucky I am not trying out beta bits again...

November 02, 2015

# re: Mysteriously stubborn IIS 401.2 Errors

Always mystified by the self-flagellation people endure installing early versions of MS products. Thankful, yes, but still mystified.

September 15, 2016

# re: Mysteriously stubborn IIS 401.2 Errors

This was a life-saver. I, too, consider myself at least an advanced level IIS admin but recently a co-worker had this exact issue and I was stumped. It has been a long time since I've seen a corrupted config so it wasn't on my radar. He just had a forced Windows 10 updated that ended up failing/freezing in the middle. His situation had nothing to do with using any beta releases of anything. This was a simple Windows update fumble which corrupted his IIS configuration. As you mentioned, uninstalling IIS and reinstalling it didn't do anything.

Thanks so much for the write-up!

West Wind  © Rick Strahl, West Wind Technologies, 2005 - 2017