ASP.NET MVC3 et Windows Auth sur IIS continuent de rediriger vers /Account/Login
Question
J'utilise MVC3 et une application Web d'authentification Windows.Lorsque je déploie sur IIS6, cela fonctionne très bien jusqu'à ce que j'atteigne une page nécessitant une authentification.Il est ensuite automatiquement redirigé vers /Account/Login lorsque je n'en ai aucune trace dans mon application et que mon web.config est configuré pour l'authentification Windows.
Des idées?
Voici l'intégralité de mon fichier web.config : http://pastie.org/1568510
La solution
Vérifiez si vous avez
Autres conseils
Dans RTM, essayez d'ajouter à <appSettings>
dans Web.config
:
<add key="enableSimpleMembership" value="false" />
(Merci à Problème utilisant exclusivement l'authentification Windows dans ASP.NET MVC 3 Beta.)
Je ne sais pas si vous avez toujours le problème ou non, mais essayez d'ajouter
<add key="autoFormsAuthentication" value="false" />
à votre web.config sous appSettings.Selon ici et
Try override WebMatrix.dll default for login url by adding this to your appSettings (web.config) :
<add key="loginUrl" value="~/Account/LogOn"/>
WebMatrix.dll set the login Url to /Account/Login, if this key isn't set in the config file... It works for me.
In RTM try to add to in Web.config:
<add key="enableSimpleMembership" value="false" />
The above post works. +1 Add this key before adding deployable dependencies.
I had the same issue in my MVC4 project, only my project has Anonymous Authentication disabled outright, so Windows Authentication is always required.
I have no WebMatrix.* in my bin folder, and adding the autoFormsAuthentication and enableSimpleMembership keys to appSettings didn't do it for me.
Instead, I had to comment out the following:
<authentication mode="Forms">
<forms loginUrl="~/Account/Login" timeout="2880" />
</authentication>
And replace it with this:
<authentication mode="Windows" />
That did the trick.
I was using nopCommerce 2.65 and had this issue.
I did not have any of WebMatrix.Data.dll nor WebMatrix.WebData.dll deployed in the bin folder, but adding
<add key="autoFormsAuthentication" value="false" />
<add key="enableSimpleMembership" value="false" />
in the web.config solved it.
Another way to override "login.aspx url redirection problem with MVC + IIS 7"... by adding this to your appSettings (web.config) :
<authentication mode="Forms">
<!--<forms loginUrl="~/Account/Login" timeout="2880" />-->
<forms loginUrl="~/Home" timeout="2880" />
</authentication>
...This resolved the problem for me
I fixed it this way
1) Go ot IIS
2) Select your Project
3) Click on "Authentication"
4) Click on "Anonymous Authentication" > Edit > select "Application pool identity" instead of "Specific User".
5) Done.
Make sure that all the authentication settings in IIS are correct.
For me the application that redirected to /Account/Login was running within a site that Anonymous authentication enabled. After disabling this in the site and enabling it for the application (together with Windows authentication) it was ok.
You can also go to the IIS on the server and go into Authentication modes and disable forms authentications.
This has me scratching my head in a demo. Embarassing.
I know this is a super old post. But I just ran across this after going through a tutorial on upgrading from MVC 4 to MVC 5. So I'm throwing it on just in case anyone else makes the mistake I did. My issue ended up being that I accidently added 'Microsoft.AspNet.WebPages.WebData' to my project while upgrading my references.
Running "Uninstall-Package Microsoft.AspNet.WebPages.WebData" restored my authentication to it's previous glory.
In MVC for the 4.6 Framework this is done in 2 ways, the first is in the Web.Config as you would expect, the second one is done in the projectfile and is used to configure IIS Express:
<PropertyGroup>
..
<IISExpressAnonymousAuthentication>enabled</IISExpressAnonymousAuthentication>
<IISExpressWindowsAuthentication>disabled</IISExpressWindowsAuthentication>
</Property
Will disable Windows authentication and use anonymous when developing but is not used for the deploying the application.