Problem with [Authorize] on asp.net mvc 4

0

please your collaboration with the following: I have a controller with a couple of actions:

    [Authorize]
    public ActionResult conAut()
    {
        return View();
    }

    public ActionResult sinAut()
    {
        return View();
    }

As you can see the difference between the two actions is that one has the [Authorize] and the other does not, in the web.config I have the following:

<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5" />
<authentication mode="Forms">
  <forms loginUrl="~/Credenciales/Login" timeout="2880" />
</authentication>
<pages>
  <namespaces>
    <add namespace="System.Web.Helpers" />
    <add namespace="System.Web.Mvc" />
    <add namespace="System.Web.Mvc.Ajax" />
    <add namespace="System.Web.Mvc.Html" />
    <add namespace="System.Web.Optimization" />
    <add namespace="System.Web.Routing" />
    <add namespace="System.Web.WebPages" />
  </namespaces>
</pages>
</system.web>

The problem is that when I start the project and I go directly to conAut, it does not redirect me to Login, it accesses conAut normally even though I do not log in, as far as I understand if in the web.config I have configured all the Actions that have the Authorize should re-address the Login when there is no authenticated user.

    
asked by RSillerico 22.11.2016 в 21:40
source

2 answers

1

You must be authenticated by the coockie of some previous login, try to close the browser and clean the cache.

    
answered by 22.11.2016 / 22:46
source
0

I think you're missing this in the web.config:

<authorization>
    <deny users="?" /> 
</authorization>
    
answered by 22.11.2016 в 22:19