I'm having difficulty deploying a web app that has forms authentication to IIS 7.5.
I have the following:
Web.Config:
<authentication mode="Forms">
<forms loginUrl="~/Account/LogOn" timeout="2880" />
</authentication>
I get the following error when running "Manage Application-->Browse" inside IIS Manager.
HTTP Error 401.2 - Unauthorized
I get the following error when trying to run the deployed app on my local machine:
401 - Unauthorized: Access is denied due to invalid credentials.
Any ideas on what is going wrong? It works find when run from VS.
If you have a path leading to an eventual [Authorize] attribute, that will cause this - removing the RenderAction or allowing that action to render without [Authorize] fixes it.
In my case, I call Html.RenderAction("Heading") in _Layout.cshtml (renders a "Please log in" or "Welcome back, Ryan"). My Heading actionresult had an AuthorizeAttribute set on it. I removed the AuthorizeAttribute on Heading, and it was resolved.
I'm running the same setup as what you've shown and it works for me. Check to make sure your logon action does not require authorization.
I got this to work by setting the "Anonymous Authentication" to enabled.
Update: Setting it to Anonymous Authetication has causes other problems. I need to keep this disabled.
Any ideas?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.