Reputation: 731
Having serious trouble getting beyond "Access is Denied" message:
Error message 401.2: Unauthorized: Logon failed due to server configuration. Verify that you have permission to view this directory or page based on the credentials you supplied and the authentication methods enabled on the Web server. Contact the Web server's administrator for additional assistance.
Running under Windows 7, Professional. System using AD for login to system (name: SYSTEM\login). Created a new MVC 3 application in VS2010 called XYZ. Made no changes to code. Set referenced files for System.Web.mvc and System.Web.Helpers to Copy to Local = true.
After all this, I reset the web site, refresh the browser, and reset IIS. I still get this message when I go to abc.xyz.com. I have absolutely no idea what I should check next.
Can anyone help me with this? I have performed several Google searches with combinations of "mvc localhost access denied" and so forth, and I implemented the suggestions I found.
Upvotes: 12
Views: 18847
Reputation: 2572
i get the error because this lines by web.config
https://www.asp.net/visual-studio/overview/2013/using-browser-link
<appsettings>
<add key="vs:EnableBrowserLink" value="false"></add>
</appsettings>
<system.web>
<compilation debug="false" targetFramework="4.5" />
</system.web>
Upvotes: 0
Reputation: 11
If you want to avoid things like wrong file copied:
My dev box:
<authentication mode="None" xdt:Transform="Replace"/>
<authorization xdt:Transform="Replace">
</authorization>
Production:
<authentication mode="Windows" xdt:Transform="Replace"/>
<authorization xdt:Transform="Replace">
<deny users="?" />
Upvotes: 1
Reputation: 37
Add this in web.config file.
<system.webServer>
<modules runAllManagedModulesForAllRequests="true" />
<!-- rest of config -->
</system.webServer>
Hope this will help. :)
Upvotes: 1
Reputation: 731
Ok. Found the answer...at least to this application. I changed the Authentication from Windows to Anonymous. Then, I removed the .NET Authorization rule which denied Anonymous access. These two things enabled access to the application without the annoying IIS login popup that accompanies Windows authorization.
One thing that I failed to notice before was that the changes I made to the web site were reflected in the web.config file at the published location, and not the source.
Unfortunately, every time I published I reset the authentication. This was probably the real reason that I had so much trouble. Lesson learned. Chagrined, I am.
One other thing that I failed to clear up was that I am using IIS 7.5.
Upvotes: 11
Reputation: 36073
When creating your MVC application, one option is to create an "Intranet" application. This will turn on "Windows" authentication by default inside Web.config
.
When publishing such a project to IIS, you need to enable Windows authentication for your application in the IIS Management Console. You may also have to disable Anonymous authentication.
Upvotes: 0