I have an asp.net 4.0 application that works fine running under cassini but when i deploy to IIS i get the above error. It is running under the Default App pool which a numb
If you are using Windows Authentication, it could be your authorization settings. Open web.config file:
<system.web>
<authentication mode="Windows"></authentication>
<identity impersonate="false" />
<authorization>
<allow roles="domain_name1\group_name1,domain_name2\group_name2" />
<deny users="*" />
</authorization>
Make sure you have assigned the correct roles. If you need to include all users, use:
<allow users="*" />
I had the same error, where the application is running fine locally, but gives Unauthorized error when running from IIS. I tried several methods but no luck. I finally used the below method:
I was using Anonymous Authentication, which was not able to work correctly as it was unable to find path to the code files. Therefore, I set the Windows Authentication to True and VOILA! it worked.
You can find Windows Authentication by clicking your application name in the left hand side pane - Select Authentication - Windows Authentication (set to Enabled).
Also, if you cannot fine Windows Authentication here, you need to select it from Control Panel - Program featutes - Turn windows fetures on or off - IIS - World wide web services - Security- Windows authentication (check it). Now go to IIS and you will find it.
This might be a very late answer, but the problem in my case was a mis-configured Publish profile (Using Web Deploy). As soon as I deselected the Precompile during publishing
option (below) and re-published, it came back to normal and I was able to access it.
I also tried activating/deactivating it a couple of time and that confirmed it was the sole reason. The problem appeared when I activated it again and disappeared when I unchecked it.
And to be honest, I still don't have an explanation about what impact does this option have exactly and why it is the cause of such problem. I found this question but I am still investigating.