Code highlighting

This commit is contained in:
Robert Fitch 2016-04-13 11:35:47 +02:00
parent da60856dee
commit 33adeef6c5

View file

@ -87,6 +87,7 @@ And the OWIN-Code to specify the on-premise authentication is in Startup.Auth.cs
});
}
}
```
# Configure the On-Premise Identity Server (Job for IT) #
@ -151,7 +152,7 @@ You may create a controller with the Authorize attribute like this:
public class RoleController : Controller
{
}
```
The **Authorize** attribute forces the user to be logged in before any requests are routed to this controller. The log in dialog will be opened automatically if necessary.
@ -168,12 +169,13 @@ Once inside a controller (or method) requiring authorization, you have access to
{
// do something else
}
```
Within a cshtml file, you may also want to react to user membership in a certain role. One way to do this is to bind the cshtml file to a model class which contains the necessary boolean flags. Set those flags in the controller, e.g.:
``` csharp
model.IsArchitect = User.IsInRole("_Architects");
```
Pass the model instance to the view, then evaluate those flags in the cshtml file:
@ -190,5 +192,6 @@ Pass the model instance to the view, then evaluate those flags in the cshtml fil
<text><b>No, you are not in the Architect group.</b></text>
</div>
}
```
Instead of using flags within the data binding model, it may be easier to have the controller just assign a property to the ViewBag and evaluate the ViewBag in the cshtml file.