Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Request redirect to /Account/Login?ReturnUrl=%2f since MVC 3 install on server

We have an internal ASP.NET Webforms application running on a Windows 2008/IIS7 server which has been running fine until we installed MVC3.

Now any requests redirect to /Account/Login?ReturnUrl=%2f.

The website is Webforms not MVC. Because it is an internal only site we have Windows Authentication enabled for the root folder.

We have several other websites on the same server that have not been affected by this problem, but this is the only site where the root folder is set to Windows Authentication.

like image 456
johna Avatar asked Nov 20 '11 22:11

johna


9 Answers

I solved the problem by adding the following lines to the AppSettings section of my web.config file:

<add key="autoFormsAuthentication" value="false" />
<add key="enableSimpleMembership" value="false"/>
like image 64
johna Avatar answered Oct 05 '22 05:10

johna


I fixed it this way

  1. Go to 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.
like image 25
Akiv Avatar answered Oct 05 '22 04:10

Akiv


Updated answer for MVC 4, heavily borrowed from this page and ASP.NET MVC issue with configuration of forms authentication section (and answered on both pages)

<appSettings>
   ...
   <add key="PreserveLoginUrl" value="true" />
</appSettings>

...

<authentication mode="Forms">
      <forms loginUrl="~/Account/LogOn" timeout="43200" /> <!--43,200 in minutes - 30 days-->
</authentication>
like image 25
Aaron Sherman Avatar answered Oct 05 '22 04:10

Aaron Sherman


Just remove

 <authorization>
      <deny users="?"/>
    </authorization>

from your web.config file

that did for me

like image 45
Avinash Avatar answered Oct 05 '22 03:10

Avinash


My solution was to add the tag

[AllowAnonymous]

over my GET request for the Register page. It was originally missing from the code I was mantaining!

like image 27
Drezus Avatar answered Oct 05 '22 03:10

Drezus


A solve this adding in the option defaultURL the path my application

<forms loginUrl="/Users/Login" protection="All" timeout="2880" name="001WVCookie" path="/" requireSSL="false" slidingExpiration="true" defaultUrl="/Home/Index" cookieless="UseCookies" enableCrossAppRedirects="false" />
like image 2
CelzioBR Avatar answered Oct 05 '22 03:10

CelzioBR


It's resolved the IIS request auto redirect to default page(default.aspx or login page)

By adding the following lines to the AppSettings section of my web.config file:

<add key="autoFormsAuthentication" value="false" />
<add key="enableSimpleMembership" value="false"/>
like image 2
tushar malvi Avatar answered Oct 05 '22 04:10

tushar malvi


We added some WCF SOAP related things to an existing IIS site and it caused this problem, with the site refusing to honour the web.config authentication redirect.

We tried the various fixes listed without success, and invented a work around of mapping the new weird URL back to the one we've been using for years:

<urlMappings enabled="true">
<add mappedUrl="~/loginout.aspx" url="~/Account/Login"/>
</urlMappings>

That worked but it's ugly. Eventually we traced it down to a web.config entry added by Visual Studio some time earlier:

<add key="webpages:Enabled" value="true" />

As we'd been unable to work out precisely what that does, we took it out, which solved the problem for us immediately.

like image 1
philw Avatar answered Oct 05 '22 05:10

philw


Open web.config,then Change

<authentication mode="Forms">
  <forms loginUrl="~/Account/Login.aspx" timeout="2880" />
</authentication>

To

<authentication mode="Forms">
  <forms loginUrl="~/Login.aspx" timeout="2880" />
</authentication>

change to ~/Default.aspx

like image 1
Suzk AL Avatar answered Oct 05 '22 03:10

Suzk AL