ASP.NET MVC with FormsAuthentication

0

I have an Asp.net MVC application with FormsAuthentication, but the need arose to release a page to the site visitor or a page is released to everyone and the rest of the controllers falls on the login screen, is it possible? / p>     

asked by anonymous 17.02.2016 / 11:55

2 answers

0

You can release the following controller by placing this code in your Web.config

 <location path="ControllerName">
    <system.web>
      <authorization>
        <allow users="*"/>
      </authorization>
    </system.web>
 </location>

If you are using Authorize, you can put in the method the implementation of [AllowAnonymous] as annotation of the same to release for unauthenticated users.

    
17.02.2016 / 12:05
0

Yes, it is possible. In your controller, or on your Action, you must have an "[Authorize]" attribute. All actions with this attribute mean that they can only be accessed if the user is authenticated, the pages that you want to leave as public, in the corresponding Actions, you do not place this attribute. Once put the attribute in the controller means that any action of that controller needs authentication.

You can also configure this via Web.config, but I think the attribute is simpler.

    
17.02.2016 / 12:04