Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>first the <code>Authorize</code> is very powerful and granular. You can use it at class level and at method level. You can also set which Roles have access to to it.</p> <pre><code>[Authorize] public class MyFirstController : Controller </code></pre> <p>You're basically saying any user that has been authenticated, you can also use </p> <pre><code>[Authorize(Roles="Administrator")] public class MyFirstController : Controller </code></pre> <p>Giving you a finer control. Here you're saying only user in the Administrator role are allowed to access these contents. Now for the <code>SeeYourDetails</code> Action you shouldn't really be be sending the user ID. If the user is currently logged in, you can access his/her details like this:</p> <pre><code>var current = Membership.GetUser(); </code></pre> <p>So you're all code would look something like this:</p> <pre><code>using System; using System.Web; using System.Web.Mvc; using System.Web.Security; using System.Collections.Generic; namespace TestArea.Controllers { [Authorize] public class MyFirstController : Controller { public ActionResult Index() { return View(); } public ActionResult SeeYourDetails() { //get the currently logged in user var current = Membership.GetUser(); //you can always do something else here return View(current); } } </code></pre> <p>} More info on the Authorize attribute <a href="http://msdn.microsoft.com/en-us/library/system.web.mvc.authorizeattribute.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/system.web.mvc.authorizeattribute.aspx</a></p> <p>last, but not least. If you gonna program in C# you should respect it's notation :-) Hope this helps</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload