Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MVC 4 Form Authentication - Cannot access any other action beside the one declared on the web.config

This is my settings at web.config:

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

On my controller I have few actions, on every action I added [AllowAnonymous] decoration, but I'm getting redirection from every action to the Login action.

I even tried to add [AllowAnonymous] decoration to the controller, but it doesn't help.

Thanks

like image 453
Shahar Avatar asked Oct 05 '22 06:10

Shahar


2 Answers

I had a similar issue and resolved it by adding the following to my web.config

<location path="Login">
    <system.web>
        <authorization>
            <allow users="?" />
        </authorization>
    </system.web>
</location>

I also had to add similar location statements to get my stylesheets, scripts, and images available prior to authentication.

Edit 1

I realized that I actually ran into this issue while running my MVC app as an application in a virtual directory, instead of being the base site. YMMV.

like image 133
scott-pascoe Avatar answered Oct 13 '22 11:10

scott-pascoe


I recently encountered this problem. Some of our team members had to switch Specific user to Application pool identity in IIS Authentication settings.

Anonymous Authentication enabled

IIS Anonymous Authentication

like image 42
Jasen Avatar answered Oct 13 '22 10:10

Jasen