-
Notifications
You must be signed in to change notification settings - Fork 127
Expand file tree
/
Copy pathHomeController.cs
More file actions
65 lines (53 loc) · 1.72 KB
/
HomeController.cs
File metadata and controls
65 lines (53 loc) · 1.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
//
using FeatureFlagDemo.Models;
using Microsoft.AspNetCore.Mvc;
using Microsoft.FeatureManagement;
using Microsoft.FeatureManagement.Mvc;
using System.Diagnostics;
namespace FeatureFlagDemo.Controllers
{
public class HomeController : Controller
{
private readonly IFeatureManager _featureManager;
public HomeController(IFeatureManagerSnapshot featureSnapshot)
{
_featureManager = featureSnapshot;
}
[FeatureGate(MyFeatureFlags.Home)]
public IActionResult Index()
{
return View();
}
public async Task<IActionResult> About()
{
ViewData["Message"] = "Your application description page.";
if (await _featureManager.IsEnabledAsync(MyFeatureFlags.CustomViewData))
{
ViewData["Message"] = $"This is FANCY CONTENT you can see only if '{MyFeatureFlags.CustomViewData}' is enabled.";
}
return View();
}
public IActionResult Contact()
{
ViewData["Message"] = "Your contact page.";
return View();
}
[FeatureGate(MyFeatureFlags.Beta)]
public IActionResult Beta()
{
ViewData["Message"] = "Your contact page.";
return View();
}
public IActionResult Privacy()
{
return View();
}
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
public IActionResult Error()
{
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
}
}
}