-
-
Notifications
You must be signed in to change notification settings - Fork 5
Asp.Net MVC Integration
FeatureSwitch Asp.Net Mvc integration provides various helpers and UI to be used in Asp.Net Mvc applications.
In order to setup FeatureSwitch library you need to do some stuff. Using Asp.Net Mvc integration library setup procedure remains the same:
var builder = new FeatureSetBuilder();
builder.Build();
Asp.Net Mvc integration library provides a built-in minimalistic implementation of control panel where you can overview features discovered so far or what's more important - enable or disable some of the writable features on-demand. Below is sample screenshot from sandbox Asp.Net Mvc application:
You have to call mapping procedure to register route to UI Control Panel. This could be done via Owin's IAppBuilder interface or through RouteCollection
class.
[assembly: OwinStartup(typeof(Startup))]
namespace FeatureSwitch.AspNet.Sample
{
public partial class Startup
{
public void Configuration(IAppBuilder app)
{
ConfigureFeatureToggle(app);
}
}
}
public partial class Startup
{
public void ConfigureFeatureToggle(IAppBuilder app)
{
var builder = new FeatureSetBuilder();
builder.Build();
app.MapFeatureSwitch();
}
}
or
public class RouteConfig
{
public static void RegisterRoutes(RouteCollection routes)
{
....
routes.MapFeatureSwitch();
}
}
By default UI Control Panel is accessible under ~/FeatureSwitch/
.
It's possible to customize route name for the control panel if it starts to conflict with something or for any other reasons. You can do it via any extension method for registering routes for control panel:
public partial class Startup
{
public void ConfigureFeatureToggle(IAppBuilder app)
{
var builder = new FeatureSetBuilder();
builder.Build();
app.MapFeatureSwitch("FancyRouteName");
}
}
public class RouteConfig
{
public static void RegisterRoutes(RouteCollection routes)
{
....
routes.MapFeatureSwitch("FancyRouteName");
}
}