ASP.NET MVC with Formsauthentication

Asked

Viewed 381 times

0

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

  • Are you using Authorize to authenticate? If so, try using the Allowanonymous attribute for this. http://stackoverflow.com/questions/9727509/how-to-allow-an-anonymous-user-access-to-some-given-page-in-mvc

2 answers

0

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

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

0


You can release the following controller by placing this code on 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 free for non-authenticated users.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.