File tree Expand file tree Collapse file tree 6 files changed +47
-2
lines changed
CustomFeatureFilter/CustomFeatureFilter Expand file tree Collapse file tree 6 files changed +47
-2
lines changed Original file line number Diff line number Diff line change 1+ using Microsoft . AspNetCore . Mvc ;
2+ using Microsoft . FeatureManagement ;
3+ using System ;
4+ using System . Collections . Generic ;
5+ using System . Linq ;
6+ using System . Threading . Tasks ;
7+
8+ namespace CustomFeatureFilter
9+ {
10+ [ Feature ( FeatureFlags . Beta ) ]
11+ public class BetaController : Controller
12+ {
13+ [ HttpGet ( "Beta" ) ]
14+ public IActionResult Index ( )
15+ {
16+ return View ( ) ;
17+ }
18+ }
19+ }
Original file line number Diff line number Diff line change 1111 <PackageReference Include =" Microsoft.AspNetCore.App" />
1212 <PackageReference Include =" Microsoft.FeatureManagement.AspNetCore" Version =" 1.0.0-preview-008560001-910" />
1313 <PackageReference Include =" Microsoft.AspNetCore.Razor.Design" Version =" 2.2.0" PrivateAssets =" All" />
14+ <PackageReference Include =" Microsoft.VisualStudio.Web.CodeGeneration.Design" Version =" 2.2.3" />
1415 </ItemGroup >
1516
1617</Project >
Original file line number Diff line number Diff line change 1- <!DOCTYPE html>
1+ @inject Microsoft .FeatureManagement .IFeatureManager _featureManager ;
2+ <!DOCTYPE html>
23<html >
34<head >
45 <meta charset =" utf-8" />
3536 <li class =" nav-item" >
3637 <a class =" nav-link text-dark" asp-area =" " asp-page =" /Privacy" >Privacy</a >
3738 </li >
39+ <feature name =" @FeatureFlags.Beta" >
40+ <li class =" nav-item" >
41+ <a class =" nav-link text-dark" asp-area =" " asp-controller =" Beta" asp-action =" Index" >Beta</a >
42+ </li >
43+ </feature >
3844 </ul >
3945 </div >
4046 </div >
Original file line number Diff line number Diff line change 1+ using System . Collections . Generic ;
2+ using System . Threading . Tasks ;
3+ using Microsoft . AspNetCore . Mvc ;
4+ using Microsoft . AspNetCore . Mvc . Filters ;
5+ using Microsoft . FeatureManagement ;
6+
7+ namespace CustomFeatureFilter
8+ {
9+ public class RedirectDisabledFeatureHandler : IDisabledFeaturesHandler
10+ {
11+ public Task HandleDisabledFeatures ( IEnumerable < string > features , ActionExecutingContext context )
12+ {
13+ context . Result = new ForbidResult ( ) ;
14+ return Task . CompletedTask ;
15+ }
16+ }
17+ }
Original file line number Diff line number Diff line change @@ -47,7 +47,8 @@ public void ConfigureServices(IServiceCollection services)
4747 services . AddMvc ( ) . SetCompatibilityVersion ( CompatibilityVersion . Version_2_2 ) ;
4848
4949 services . AddFeatureManagement ( )
50- . AddFeatureFilter < ClaimsFeatureFilter > ( ) ;
50+ . AddFeatureFilter < ClaimsFeatureFilter > ( )
51+ . UseDisabledFeaturesHandler ( new RedirectDisabledFeatureHandler ( ) ) ;
5152 }
5253
5354 // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
Original file line number Diff line number Diff line change 1+ This is super-secret beta stuff
You can’t perform that action at this time.
0 commit comments