What!? Orchard CMS with Owin throwing some sorta weird "No owin.Environment item was found in the context" error under IIS?

#orchard #owin

Posted by admin on September 01, 2019

Today I decided to get OWIN up and running on Orchard. Sebastien had done the leg work, I just needed to get it compiling, update the DLL packages for Owin, and get those unit tests running. Fantastic, not hard.. but hang on!! What's this error!

No owin.Environment item was found in the context

After lots of googling, it appears that this error will only occur if the Owin Startup class is not called.

I fire up IIS Express, and hey presto, it works, Orchard kicks up, so the issue is IIS!

So I cleared my cache, deleted dependencies, cleaned, rebuilt, still issues.... ultimately, its the ASP.Net temporary files that are going to kick ya. Just do this..

Run this in PowerShell

net stop w3svc
Remove-Item -Path "C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\*" -Force -Recurse
Remove-Item -Path "C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\*" -Force -Recurse
net start w3svc