Click here to Skip to main content
15,896,912 members
Articles / Security

Manage security and redirection for non authorized access in MVC

Rate me:
Please Sign up or sign in to vote.
4.50/5 (7 votes)
18 Jul 2012CPOL2 min read 56.6K   1.4K   26  
How to apply security and redirection to a view when a user cannot access a controller or a controller action in MVC
@{
    ViewBag.Title = "Home Page";
}

<h2>@ViewBag.Message</h2>
<p>
    Site privileges.
</p>

<ul>
    <li><span class="blue">Home</span> = <span class="red">Everyone</span></li>
    <li><span class="blue">User Info</span> = <span class="red">UserInfo_Reader</span> Role</li>
    <li><span class="blue">View With Render Action</span> = <span class="red">SimpleUser</span> Role <br />
        <span class="blue">Render Action</span> = <span class="red">RenderAction_Reader</span> Role
    </li>
    <li><span class="blue">Current User Roles (read)</span> = <span class="red">SimpleUser</span> Or <span class="red">SuperUser</span> Roles<br />
        <span class="blue">Current User Roles (save)</span> = <span class="red">SuperUser</span> Role
    </li>
    <li><span class="blue">About</span> = <span class="red">About_Reader Role</span></li>
    <li><span class="blue">Apply Default Roles</span> = <span class="red">Everyone</span></li>
</ul>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Architect CGI
Canada Canada
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions