[英]ASP.NET MVC Deploying an app with forms authentication to IIS 7.5
I'm having difficulty deploying a web app that has forms authentication to IIS 7.5. 我很难将具有表单身份验证的Web应用程序部署到IIS 7.5。
I have the following: 我有以下内容:
Web.Config: 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. 在IIS管理器中运行“管理应用程序->浏览”时,出现以下错误。
HTTP Error 401.2 - Unauthorized HTTP错误401.2-未经授权
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. 401-未经授权:由于凭据无效,访问被拒绝。
Any ideas on what is going wrong? 对出什么问题有任何想法吗? It works find when run from VS.
从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. 如果您有通往最终[Authorize]属性的路径,则将导致此情况-删除RenderAction或允许该动作在没有[Authorize]的情况下进行修复。
In my case, I call Html.RenderAction("Heading") in _Layout.cshtml (renders a "Please log in" or "Welcome back, Ryan"). 就我而言,我在_Layout.cshtml中调用Html.RenderAction(“ Heading”)(提供“请登录”或“欢迎回来,瑞安”)。 My Heading actionresult had an AuthorizeAttribute set on it.
我的标题actionresult结果上设置了AuthorizeAttribute。 I removed the AuthorizeAttribute on Heading, and it was resolved.
我在标题上删除了AuthorizeAttribute,并已解决。
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? 有任何想法吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.