Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You can show the pages in different ways by testing what kind of user it is</p> <p>In my _Layout.cshtml i have this:</p> <pre><code>@if (Request.IsAuthenticated &amp;&amp; HttpContext.Current.User.IsInRole("Interviewer")) { &lt;script type="text/javascript"&gt; $("#logindisplay").show(); &lt;/script&gt; &lt;li&gt;@Html.ActionLink("Forside", "Index", "Home")&lt;/li&gt; &lt;li&gt;@Html.ActionLink("Spørgeskema", "Index", "Survey2")&lt;/li&gt; &lt;li&gt;@Html.ActionLink("Brugere", "Index", "UserAdministration")&lt;/li&gt; &lt;li&gt;@Html.ActionLink("Statistik", "Index", "Statistik")&lt;/li&gt; &lt;li&gt;@Html.ActionLink("Vagtplan", "Vagtplan", "Statistik")&lt;/li&gt; } @if (HttpContext.Current.User.IsInRole("Respondent")) { &lt;li&gt;@Html.ActionLink("Gammelt spørgeskema", "Index")&lt;/li&gt; } </code></pre> <p>And so on.</p> <p>You could create different DisplayTemplates for each kind of role and display these based upon which role the user has.</p> <p>To manually assign Roles to different users, use ASP.NET Configuration </p> <p><img src="https://i.stack.imgur.com/dGbjz.jpg" alt="ASP.NET Configuration"></p> <p>From there, you can create your roles and manage users.</p> <p>You do not want to do this in the long run, if you get a lot of users on your site. Instead, when they create an account, you would want to assign their role automatically.</p> <p>You can do this in your AccountController, for instance like this:</p> <pre><code>if (createStatus == MembershipCreateStatus.Success) { Roles.AddUserToRole(model.UserName, "Respondent"); } .... </code></pre> <p>Your model could have the Role property instead of hardcoding it.</p>
    singulars
    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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      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