简体   繁体   English

ASP.NET MVC将具有表单身份验证的应用程序部署到IIS 7.5

[英]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: 我有以下内容:

  • Forms Authentication 表格认证
  • Asp.net mvc 2 ASP.NET MVC 2
  • Net Framework 4.0 Net Framework 4.0
  • Application Pool is setup for .Net Framework 4.0 and is in Integrated pipeline mode. 应用程序池是为.Net Framework 4.0设置的,处于集成管道模式。
  • IIS 7.5 on Windows Server 2008 Windows Server 2008上的IIS 7.5
  • Authentication setup is IIS (ASP.NET Impersonation and Forms Authentication set to ENABLED. The rest set to DISABLED). 身份验证设置为IIS(ASP.NET模拟和表单身份验证设置为ENABLED,其余设置为DISABLED)。 Inside the settings for Forms authentication the login URL is correct. 在表单身份验证设置中,登录URL是正确的。 The cookie settings is (Mode: Use device profile, Name: .ASPXAUTH, Protection Mode: Encryption and validation, Requires SSL: not checked) cookie设置为(模式:使用设备配置文件,名称:.ASPXAUTH,保护模式:加密和验证,需要SSL:未选中)

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-未经授权

You are not authorized to view this page due to invalid authentication headers. 由于身份验证标题无效,因此您无权查看此页面。

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-未经授权:由于凭据无效,访问被拒绝。

You do not have permission to view this directory or page using the credentials that you supplied. 您无权使用您提供的凭据查看此目录或页面。

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(“ H​​eading”)(提供“请登录”或“欢迎回来,瑞安”)。 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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM