ASP.NET MVC Deploying an app with forms authentication to IIS 7.5
NickName:Elim99 Ask DateTime:2011-11-16T01:48:01

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.

I have the following:

  • Forms Authentication
  • Asp.net mvc 2
  • Net Framework 4.0
  • Application Pool is setup for .Net Framework 4.0 and is in Integrated pipeline mode.
  • IIS 7.5 on Windows Server 2008
  • Authentication setup is IIS (ASP.NET Impersonation and Forms Authentication set to ENABLED. The rest set to DISABLED). Inside the settings for Forms authentication the login URL is correct. The cookie settings is (Mode: Use device profile, Name: .ASPXAUTH, Protection Mode: Encryption and validation, Requires SSL: not checked)

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

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.

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.

Copyright Notice:Content Author:「Elim99」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/8140780/asp-net-mvc-deploying-an-app-with-forms-authentication-to-iis-7-5

Answers
Ryan Faricy 2011-12-14T04:47:07

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.\n\nIn 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.",


Brian 2011-11-15T17:54:57

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.",


More about “ASP.NET MVC Deploying an app with forms authentication to IIS 7.5” related questions

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. I have the following: Forms Authentication Asp.net mvc 2 Net Framework 4.0 Application Pool is setup for .Net

Show Detail

How can I mix Forms Authentication and Windows Authentication in MVC 2 in IIS 7.5?

I've seen this posted alot that solves the problem if you are running ASP.Net application not a MVC 2 one in IIS 7.5. Would the same solution work using location in the web.config and 2 seperate l...

Show Detail

Forms Authentication with IIS 7.5 - Not Authorized

I have a Web application deployed to Windows Server 2008 R2 with IIS 7.5. The application is ASP.NET MVC 3 with .Net Framework 4.0. Authentication Settings: Anonymous and Forms Authentication is

Show Detail

Basic authentication on IIS 7.5

I'm trying to run a simple ASP.NET application with basic authentication on an IIS server. Interestingly, the authentication works fine on almost all servers except my production server. When I dep...

Show Detail

Run (deploy?) ASP.NET MVC on IIS 7.5 locally

I am a Web Designer, not a programmer, specially not an ASP.NET MVC programmer. At my work there are no programmers anymore. The application was developed by a contracted programmer and the contra...

Show Detail

Best method to connect IIS 7.5 Web Forms to SQL Server

I'm upgrading an ASP.NET 4.0 app from: Windows Server 2003 and IIS 6 to: Windows Server 2008 and IIS 7.5 This app is based on ASP.NET Web Forms and not MVC. I currently use SQL authentication, ...

Show Detail

IIS 7.5 and making anonymous authentication/forms authentication play nicely together

I've got an ASP.NET MVC 4 application that I run under the site level of an IIS web site. So the dir structure looks like this: \IIS \Site \bin \Content \Views The MV...

Show Detail

Deploying MVC4 App on IIS7.5

I'm trying to deploy MVC4 on IIS7.5 but i have some issues. I have installed Windows Server 2008 R2 installed .NET 4.0 installed Web Deployment 64 Tool installed IIS 7.5 role (With ASP.NET and

Show Detail

IIS 7.5 with asp.net mvc webservice

what's up? I'm facing a problem with IIS 7.5 application, asp.net MVC 3 and a set of web services. I created a new web application on port 80 with contains an asp.net mvc web site, that works nice...

Show Detail

ASP.NET MVC 3 setup for IIS7.5 with RESTful Verbs

I have a restful controller that has your standard REST HTTP Verbs: Get,Post, Put, Delete. The problem I am having is that although my controllers are decorated to accept these verbs, when I execut...

Show Detail