Brian Hvarregaard
Brian Hvarregaard

Reputation: 4209

Asp.NET MVC and security

I am planning a new portal solution in ASP.NET MVC. I need to be able to have some parts of the site visible for everyone (public part) and a part where only registered users are allowed to visit. In traditional Web Forms the security was made on folder level, but how about ASP.NET MVC? Could someone please explain me how to do this - or if its more beneficial to go the web forms way.

/H4mm3rHEad

Upvotes: 1

Views: 276

Answers (2)

John Farrell
John Farrell

Reputation: 24754

Security is mostly done on the Controller or Action level via attributes. More information on the Authorize attribute can be found here:

http://msdn.microsoft.com/en-us/library/system.web.mvc.authorizeattribute%28VS.100%29.aspx#using_authorizeattribute

You can easily see how it works by going File-> New MVC project and checking out the AccountController.cs file inside the /Controllers/ directory.

Be aware the answers by Vitaly and Agent_9191 are not current and reference mostly preview MVC builds. Those articles may reference code and or functionality that does not exist or has been depreciated.

Upvotes: 3

Agent_9191
Agent_9191

Reputation: 7253

Take a look at this post talking about the AuthorizeAttribute. It can be applied to specific actions or an entire controller.

Upvotes: 0

Related Questions