BaseController With Dependency Injection

Recently I have inherited an ASP.NET core application, which is also my first time working with the framework. Working with the application initializing controllers felt very repetitive since all controllers used a few common services like loggers. ASP.NET core makes service access easy with dependency injection, but it’s challenging to stay true to the DRY […]

ASP.NET MVC 5 Custom Role Providers for Windows Authentication

With MVC, restricting access to actions has never been easier. The AuthorizeAttribute allows you to easily restrict access to controllers or actions based on a user’s role. See the example below. 1 2 3 4 5 6 7 8 9 10 11 12 [Authorize(Roles = “Administrator, PowerUser”)] public class ControlPanelController : Controller { public […]

Custom Attribute Routing in ASP.NET MVC 5

Introduction A previous blog post discussed how to enable and use the basics of attribute routing within an MVC application. The blog also touched upon URI parameter constraints and the out-of-the-box constraints with MVC 5. The general syntax for imposing constraint is {parameter:constraint} Below is a list of constraints with examples: Constraint Description Example alpha […]

Attribute Routing in ASP.NET MVC 5

Introduction Attribute Routing was introduced with the release of MVC 5 and allows developers to define routes on controller actions and at the controller class level. At its core, Attribute Routing still maintains the same mechanism of the routing framework. With the conventional based routing, the routes are physically separated in a single from the […]