I almost went crazy with this one.
The Scenario :-
I installed IIS 7.5 on a fresh Windows 2008 box. Got a website up and running on it. Then added a Virtual Directory for all the site’s assets and thought I am done. But no! None of the assets were visible in browser. I tried in different browsers but no use. I then tried browsing to the images directly in the address bar. Then I noticed that they were all throwing 401 errors. 401. To be more precise :- 401 – Unauthorized: Access is denied due to invalid credentials.
I thought this must be one of the permissions issue. I went ahead and added all the possible options to the physical path. ie IIS_USRS, IUSR, ANONYMOUS, NETWORK SERVICE. Ofcourse, I didn’t add them in one go. I added them one by one after searching on Google for a possible solution first. The whole process took about 2-3 hours. But no use. Images still won’t work.
Source of the Problem :-
All these assets, I had basically uploaded them as a large zip file on the server and then unzipped them into physical path of the virtual directory. And the zip file was created on my Mac. Who would assume that this will be the problem but it was the problem indeed. Apparently, Windows 2008 encrypts all the files while unzipping any file that was zipped up on a Mac. It’s also worth mentioning that the zip file was downloaded from a https server. So whether it was the https or the Mac, I am not entirely sure yet, but one of those caused the problem. Windows 2008 makes all the files green which is a sign that it has encrypted them.
And IIS does not serve any files that are encrypted. Hence, the 401!
The Solution :-
Select all the green files/folders, go to Properties, then ‘Advanced’ and uncheck ‘Encrypt contents to secure data’
Once you do this, Windows will take a few minutes to do all the de-cryption. Once that’s done, you should be back to normal and back in business 🙂
I hope this helps someone else save numerous number of hours.
Hi,
This happens to me all the time, if this fixes it then I’ll be very impressed, I normally have to copy and paste the files again, to re do the file permissions.
Fingers crossed 🙂
Hi Shaun, that actually fixed it for me and didn’t have to copy/paste again.
Thanks! I had the same issue and this fixed it.
I am sending you an early thank you, I have yet to try this, but I think it’s gonna be the solution I’ve been searching for and was then lucky enough to find your post. Thanks in advance, got my fingers crossed. 🙂
This is helpful, well i dont know about windows 2008, thus this post applicable for windows 7 if things exist with same problem? im confused about this but thank you anyway for this post.
Best regards,
Tito
Kinda sure that this will solve my issues and I’m confident to solve this. Just can’t wait to try it..thank you much for this blog!
I lost 2-3 hours of my life on this one, on the Friday of a holiday weekend no less. Been working with IIS for 5 years and never encountered this.
Had this problem too and I was lucky enough to come across this article quite quickly, which has solved my problem. Key indicator is that the folders and files appear in green in Windows Explorer showing that they are encrypted.
thank you so much for posting this solution. I spent the last hour following the exact same process as you did..
The unchecking of encrypt contents fixed it for me..
Sweet! That helped a bunch. IIS does not serve encrypted files. Good to know.
Wasted all my time in changing permissions…such a noob I am ….thanks bro… A big hug.. Should work as expected….will try it tommorow at work
This is wonderful post and no tech forum(Microsoft) covers this 🙂