From a9ed468cfa1decd38eaf9eef9b2f4d0da71e7181 Mon Sep 17 00:00:00 2001 From: Ross Grambo Date: Mon, 26 Aug 2024 11:09:43 -0700 Subject: [PATCH 1/5] Renames project and cleans up startup code + auth --- Microsoft.FeatureManagement.sln | 2 +- README.md | 2 +- .../HttpContextTargetingContextAccessor.cs | 53 ------------------ .../Pages/RandomizeUser.cshtml | 4 -- .../Pages/RandomizeUser.cshtml.cs | 18 ------ .../Pages/Checkout.cshtml | 0 .../Pages/Checkout.cshtml.cs | 2 +- .../Pages/Error.cshtml | 0 .../Pages/Error.cshtml.cs | 2 +- .../Pages/Index.cshtml | 0 .../Pages/Index.cshtml.cs | 4 +- .../Pages/RandomizeUser.cshtml | 4 ++ .../Pages/RandomizeUser.cshtml.cs | 30 ++++++++++ .../Pages/Shared/_Layout.cshtml | 10 ++-- .../Pages/Shared/_Layout.cshtml.css | 0 .../Shared/_ValidationScriptsPartial.cshtml | 0 .../Pages/_ViewImports.cshtml | 4 +- .../Pages/_ViewStart.cshtml | 0 .../Program.cs | 21 +++---- .../README.md | 0 .../VariantAndTelemetryDemo.csproj} | 2 +- .../appsettings.Development.json | 0 .../appsettings.json | 0 .../wwwroot/css/site.css | 0 .../wwwroot/favicon.ico | Bin .../wwwroot/js/site.js | 0 .../wwwroot/lib/bootstrap/LICENSE | 0 .../lib/bootstrap/dist/css/bootstrap-grid.css | 0 .../bootstrap/dist/css/bootstrap-grid.css.map | 0 .../bootstrap/dist/css/bootstrap-grid.min.css | 0 .../dist/css/bootstrap-grid.min.css.map | 0 .../bootstrap/dist/css/bootstrap-grid.rtl.css | 0 .../dist/css/bootstrap-grid.rtl.css.map | 0 .../dist/css/bootstrap-grid.rtl.min.css | 0 .../dist/css/bootstrap-grid.rtl.min.css.map | 0 .../bootstrap/dist/css/bootstrap-reboot.css | 0 .../dist/css/bootstrap-reboot.css.map | 0 .../dist/css/bootstrap-reboot.min.css | 0 .../dist/css/bootstrap-reboot.min.css.map | 0 .../dist/css/bootstrap-reboot.rtl.css | 0 .../dist/css/bootstrap-reboot.rtl.css.map | 0 .../dist/css/bootstrap-reboot.rtl.min.css | 0 .../dist/css/bootstrap-reboot.rtl.min.css.map | 0 .../dist/css/bootstrap-utilities.css | 0 .../dist/css/bootstrap-utilities.css.map | 0 .../dist/css/bootstrap-utilities.min.css | 0 .../dist/css/bootstrap-utilities.min.css.map | 0 .../dist/css/bootstrap-utilities.rtl.css | 0 .../dist/css/bootstrap-utilities.rtl.css.map | 0 .../dist/css/bootstrap-utilities.rtl.min.css | 0 .../css/bootstrap-utilities.rtl.min.css.map | 0 .../lib/bootstrap/dist/css/bootstrap.css | 0 .../lib/bootstrap/dist/css/bootstrap.css.map | 0 .../lib/bootstrap/dist/css/bootstrap.min.css | 0 .../bootstrap/dist/css/bootstrap.min.css.map | 0 .../lib/bootstrap/dist/css/bootstrap.rtl.css | 0 .../bootstrap/dist/css/bootstrap.rtl.css.map | 0 .../bootstrap/dist/css/bootstrap.rtl.min.css | 0 .../dist/css/bootstrap.rtl.min.css.map | 0 .../lib/bootstrap/dist/js/bootstrap.bundle.js | 0 .../bootstrap/dist/js/bootstrap.bundle.js.map | 0 .../bootstrap/dist/js/bootstrap.bundle.min.js | 0 .../dist/js/bootstrap.bundle.min.js.map | 0 .../lib/bootstrap/dist/js/bootstrap.esm.js | 0 .../bootstrap/dist/js/bootstrap.esm.js.map | 0 .../bootstrap/dist/js/bootstrap.esm.min.js | 0 .../dist/js/bootstrap.esm.min.js.map | 0 .../lib/bootstrap/dist/js/bootstrap.js | 0 .../lib/bootstrap/dist/js/bootstrap.js.map | 0 .../lib/bootstrap/dist/js/bootstrap.min.js | 0 .../bootstrap/dist/js/bootstrap.min.js.map | 0 .../jquery-validation-unobtrusive/LICENSE.txt | 0 .../jquery.validate.unobtrusive.js | 0 .../jquery.validate.unobtrusive.min.js | 0 .../wwwroot/lib/jquery-validation/LICENSE.md | 0 .../dist/additional-methods.js | 0 .../dist/additional-methods.min.js | 0 .../jquery-validation/dist/jquery.validate.js | 0 .../dist/jquery.validate.min.js | 0 .../wwwroot/lib/jquery/LICENSE.txt | 0 .../wwwroot/lib/jquery/dist/jquery.js | 0 .../wwwroot/lib/jquery/dist/jquery.min.js | 0 .../wwwroot/lib/jquery/dist/jquery.min.map | 0 83 files changed, 59 insertions(+), 99 deletions(-) delete mode 100644 examples/EvaluationDataToApplicationInsights/HttpContextTargetingContextAccessor.cs delete mode 100644 examples/EvaluationDataToApplicationInsights/Pages/RandomizeUser.cshtml delete mode 100644 examples/EvaluationDataToApplicationInsights/Pages/RandomizeUser.cshtml.cs rename examples/{EvaluationDataToApplicationInsights => VariantAndTelemetryDemo}/Pages/Checkout.cshtml (100%) rename examples/{EvaluationDataToApplicationInsights => VariantAndTelemetryDemo}/Pages/Checkout.cshtml.cs (67%) rename examples/{EvaluationDataToApplicationInsights => VariantAndTelemetryDemo}/Pages/Error.cshtml (100%) rename examples/{EvaluationDataToApplicationInsights => VariantAndTelemetryDemo}/Pages/Error.cshtml.cs (92%) rename examples/{EvaluationDataToApplicationInsights => VariantAndTelemetryDemo}/Pages/Index.cshtml (100%) rename examples/{EvaluationDataToApplicationInsights => VariantAndTelemetryDemo}/Pages/Index.cshtml.cs (94%) create mode 100644 examples/VariantAndTelemetryDemo/Pages/RandomizeUser.cshtml create mode 100644 examples/VariantAndTelemetryDemo/Pages/RandomizeUser.cshtml.cs rename examples/{EvaluationDataToApplicationInsights => VariantAndTelemetryDemo}/Pages/Shared/_Layout.cshtml (85%) rename examples/{EvaluationDataToApplicationInsights => VariantAndTelemetryDemo}/Pages/Shared/_Layout.cshtml.css (100%) rename examples/{EvaluationDataToApplicationInsights => VariantAndTelemetryDemo}/Pages/Shared/_ValidationScriptsPartial.cshtml (100%) rename examples/{EvaluationDataToApplicationInsights => VariantAndTelemetryDemo}/Pages/_ViewImports.cshtml (66%) rename examples/{EvaluationDataToApplicationInsights => VariantAndTelemetryDemo}/Pages/_ViewStart.cshtml (100%) rename examples/{EvaluationDataToApplicationInsights => VariantAndTelemetryDemo}/Program.cs (72%) rename examples/{EvaluationDataToApplicationInsights => VariantAndTelemetryDemo}/README.md (100%) rename examples/{EvaluationDataToApplicationInsights/EvaluationDataToApplicationInsights.csproj => VariantAndTelemetryDemo/VariantAndTelemetryDemo.csproj} (94%) rename examples/{EvaluationDataToApplicationInsights => VariantAndTelemetryDemo}/appsettings.Development.json (100%) rename examples/{EvaluationDataToApplicationInsights => VariantAndTelemetryDemo}/appsettings.json (100%) rename examples/{EvaluationDataToApplicationInsights => VariantAndTelemetryDemo}/wwwroot/css/site.css (100%) rename examples/{EvaluationDataToApplicationInsights => VariantAndTelemetryDemo}/wwwroot/favicon.ico (100%) rename examples/{EvaluationDataToApplicationInsights => VariantAndTelemetryDemo}/wwwroot/js/site.js (100%) rename examples/{EvaluationDataToApplicationInsights => VariantAndTelemetryDemo}/wwwroot/lib/bootstrap/LICENSE (100%) rename examples/{EvaluationDataToApplicationInsights => VariantAndTelemetryDemo}/wwwroot/lib/bootstrap/dist/css/bootstrap-grid.css (100%) rename examples/{EvaluationDataToApplicationInsights => VariantAndTelemetryDemo}/wwwroot/lib/bootstrap/dist/css/bootstrap-grid.css.map (100%) rename examples/{EvaluationDataToApplicationInsights => VariantAndTelemetryDemo}/wwwroot/lib/bootstrap/dist/css/bootstrap-grid.min.css (100%) rename examples/{EvaluationDataToApplicationInsights => VariantAndTelemetryDemo}/wwwroot/lib/bootstrap/dist/css/bootstrap-grid.min.css.map (100%) rename examples/{EvaluationDataToApplicationInsights => VariantAndTelemetryDemo}/wwwroot/lib/bootstrap/dist/css/bootstrap-grid.rtl.css (100%) rename examples/{EvaluationDataToApplicationInsights => VariantAndTelemetryDemo}/wwwroot/lib/bootstrap/dist/css/bootstrap-grid.rtl.css.map (100%) rename examples/{EvaluationDataToApplicationInsights => VariantAndTelemetryDemo}/wwwroot/lib/bootstrap/dist/css/bootstrap-grid.rtl.min.css (100%) rename examples/{EvaluationDataToApplicationInsights => VariantAndTelemetryDemo}/wwwroot/lib/bootstrap/dist/css/bootstrap-grid.rtl.min.css.map (100%) rename examples/{EvaluationDataToApplicationInsights => VariantAndTelemetryDemo}/wwwroot/lib/bootstrap/dist/css/bootstrap-reboot.css (100%) rename examples/{EvaluationDataToApplicationInsights => VariantAndTelemetryDemo}/wwwroot/lib/bootstrap/dist/css/bootstrap-reboot.css.map (100%) rename examples/{EvaluationDataToApplicationInsights => VariantAndTelemetryDemo}/wwwroot/lib/bootstrap/dist/css/bootstrap-reboot.min.css (100%) rename examples/{EvaluationDataToApplicationInsights => VariantAndTelemetryDemo}/wwwroot/lib/bootstrap/dist/css/bootstrap-reboot.min.css.map (100%) rename examples/{EvaluationDataToApplicationInsights => VariantAndTelemetryDemo}/wwwroot/lib/bootstrap/dist/css/bootstrap-reboot.rtl.css (100%) rename examples/{EvaluationDataToApplicationInsights => VariantAndTelemetryDemo}/wwwroot/lib/bootstrap/dist/css/bootstrap-reboot.rtl.css.map (100%) rename examples/{EvaluationDataToApplicationInsights => VariantAndTelemetryDemo}/wwwroot/lib/bootstrap/dist/css/bootstrap-reboot.rtl.min.css (100%) rename examples/{EvaluationDataToApplicationInsights => VariantAndTelemetryDemo}/wwwroot/lib/bootstrap/dist/css/bootstrap-reboot.rtl.min.css.map (100%) rename examples/{EvaluationDataToApplicationInsights => VariantAndTelemetryDemo}/wwwroot/lib/bootstrap/dist/css/bootstrap-utilities.css (100%) rename examples/{EvaluationDataToApplicationInsights => VariantAndTelemetryDemo}/wwwroot/lib/bootstrap/dist/css/bootstrap-utilities.css.map (100%) rename examples/{EvaluationDataToApplicationInsights => VariantAndTelemetryDemo}/wwwroot/lib/bootstrap/dist/css/bootstrap-utilities.min.css (100%) rename examples/{EvaluationDataToApplicationInsights => VariantAndTelemetryDemo}/wwwroot/lib/bootstrap/dist/css/bootstrap-utilities.min.css.map (100%) rename examples/{EvaluationDataToApplicationInsights => VariantAndTelemetryDemo}/wwwroot/lib/bootstrap/dist/css/bootstrap-utilities.rtl.css (100%) rename examples/{EvaluationDataToApplicationInsights => VariantAndTelemetryDemo}/wwwroot/lib/bootstrap/dist/css/bootstrap-utilities.rtl.css.map (100%) rename examples/{EvaluationDataToApplicationInsights => VariantAndTelemetryDemo}/wwwroot/lib/bootstrap/dist/css/bootstrap-utilities.rtl.min.css (100%) rename examples/{EvaluationDataToApplicationInsights => VariantAndTelemetryDemo}/wwwroot/lib/bootstrap/dist/css/bootstrap-utilities.rtl.min.css.map (100%) rename examples/{EvaluationDataToApplicationInsights => VariantAndTelemetryDemo}/wwwroot/lib/bootstrap/dist/css/bootstrap.css (100%) rename examples/{EvaluationDataToApplicationInsights => VariantAndTelemetryDemo}/wwwroot/lib/bootstrap/dist/css/bootstrap.css.map (100%) rename examples/{EvaluationDataToApplicationInsights => VariantAndTelemetryDemo}/wwwroot/lib/bootstrap/dist/css/bootstrap.min.css (100%) rename examples/{EvaluationDataToApplicationInsights => VariantAndTelemetryDemo}/wwwroot/lib/bootstrap/dist/css/bootstrap.min.css.map (100%) rename examples/{EvaluationDataToApplicationInsights => VariantAndTelemetryDemo}/wwwroot/lib/bootstrap/dist/css/bootstrap.rtl.css (100%) rename examples/{EvaluationDataToApplicationInsights => VariantAndTelemetryDemo}/wwwroot/lib/bootstrap/dist/css/bootstrap.rtl.css.map (100%) rename examples/{EvaluationDataToApplicationInsights => VariantAndTelemetryDemo}/wwwroot/lib/bootstrap/dist/css/bootstrap.rtl.min.css (100%) rename examples/{EvaluationDataToApplicationInsights => VariantAndTelemetryDemo}/wwwroot/lib/bootstrap/dist/css/bootstrap.rtl.min.css.map (100%) rename examples/{EvaluationDataToApplicationInsights => VariantAndTelemetryDemo}/wwwroot/lib/bootstrap/dist/js/bootstrap.bundle.js (100%) rename examples/{EvaluationDataToApplicationInsights => VariantAndTelemetryDemo}/wwwroot/lib/bootstrap/dist/js/bootstrap.bundle.js.map (100%) rename examples/{EvaluationDataToApplicationInsights => VariantAndTelemetryDemo}/wwwroot/lib/bootstrap/dist/js/bootstrap.bundle.min.js (100%) rename examples/{EvaluationDataToApplicationInsights => VariantAndTelemetryDemo}/wwwroot/lib/bootstrap/dist/js/bootstrap.bundle.min.js.map (100%) rename examples/{EvaluationDataToApplicationInsights => VariantAndTelemetryDemo}/wwwroot/lib/bootstrap/dist/js/bootstrap.esm.js (100%) rename examples/{EvaluationDataToApplicationInsights => VariantAndTelemetryDemo}/wwwroot/lib/bootstrap/dist/js/bootstrap.esm.js.map (100%) rename examples/{EvaluationDataToApplicationInsights => VariantAndTelemetryDemo}/wwwroot/lib/bootstrap/dist/js/bootstrap.esm.min.js (100%) rename examples/{EvaluationDataToApplicationInsights => VariantAndTelemetryDemo}/wwwroot/lib/bootstrap/dist/js/bootstrap.esm.min.js.map (100%) rename examples/{EvaluationDataToApplicationInsights => VariantAndTelemetryDemo}/wwwroot/lib/bootstrap/dist/js/bootstrap.js (100%) rename examples/{EvaluationDataToApplicationInsights => VariantAndTelemetryDemo}/wwwroot/lib/bootstrap/dist/js/bootstrap.js.map (100%) rename examples/{EvaluationDataToApplicationInsights => VariantAndTelemetryDemo}/wwwroot/lib/bootstrap/dist/js/bootstrap.min.js (100%) rename examples/{EvaluationDataToApplicationInsights => VariantAndTelemetryDemo}/wwwroot/lib/bootstrap/dist/js/bootstrap.min.js.map (100%) rename examples/{EvaluationDataToApplicationInsights => VariantAndTelemetryDemo}/wwwroot/lib/jquery-validation-unobtrusive/LICENSE.txt (100%) rename examples/{EvaluationDataToApplicationInsights => VariantAndTelemetryDemo}/wwwroot/lib/jquery-validation-unobtrusive/jquery.validate.unobtrusive.js (100%) rename examples/{EvaluationDataToApplicationInsights => VariantAndTelemetryDemo}/wwwroot/lib/jquery-validation-unobtrusive/jquery.validate.unobtrusive.min.js (100%) rename examples/{EvaluationDataToApplicationInsights => VariantAndTelemetryDemo}/wwwroot/lib/jquery-validation/LICENSE.md (100%) rename examples/{EvaluationDataToApplicationInsights => VariantAndTelemetryDemo}/wwwroot/lib/jquery-validation/dist/additional-methods.js (100%) rename examples/{EvaluationDataToApplicationInsights => VariantAndTelemetryDemo}/wwwroot/lib/jquery-validation/dist/additional-methods.min.js (100%) rename examples/{EvaluationDataToApplicationInsights => VariantAndTelemetryDemo}/wwwroot/lib/jquery-validation/dist/jquery.validate.js (100%) rename examples/{EvaluationDataToApplicationInsights => VariantAndTelemetryDemo}/wwwroot/lib/jquery-validation/dist/jquery.validate.min.js (100%) rename examples/{EvaluationDataToApplicationInsights => VariantAndTelemetryDemo}/wwwroot/lib/jquery/LICENSE.txt (100%) rename examples/{EvaluationDataToApplicationInsights => VariantAndTelemetryDemo}/wwwroot/lib/jquery/dist/jquery.js (100%) rename examples/{EvaluationDataToApplicationInsights => VariantAndTelemetryDemo}/wwwroot/lib/jquery/dist/jquery.min.js (100%) rename examples/{EvaluationDataToApplicationInsights => VariantAndTelemetryDemo}/wwwroot/lib/jquery/dist/jquery.min.map (100%) diff --git a/Microsoft.FeatureManagement.sln b/Microsoft.FeatureManagement.sln index 3b8c8661..65481890 100644 --- a/Microsoft.FeatureManagement.sln +++ b/Microsoft.FeatureManagement.sln @@ -25,7 +25,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TargetingConsoleApp", "exam EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.FeatureManagement.Telemetry.ApplicationInsights", "src\Microsoft.FeatureManagement.Telemetry.ApplicationInsights\Microsoft.FeatureManagement.Telemetry.ApplicationInsights.csproj", "{7964DC66-B2D3-412D-B18A-86D1E07D149D}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EvaluationDataToApplicationInsights", "examples\EvaluationDataToApplicationInsights\EvaluationDataToApplicationInsights.csproj", "{1502529E-47E9-4306-98C4-BF6CF7C7C275}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "VariantAndTelemetryDemo", "examples\VariantAndTelemetryDemo\VariantAndTelemetryDemo.csproj", "{1502529E-47E9-4306-98C4-BF6CF7C7C275}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BlazorServerApp", "examples\BlazorServerApp\BlazorServerApp.csproj", "{12BAB5A6-4EEB-4917-B5D9-4AFB6253008E}" EndProject diff --git a/README.md b/README.md index 5c9718c4..22acae9f 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ Feature management provides a way to develop and expose application functionalit * [ASP.NET Core Web App (Razor Page)](./examples/RazorPages) * [ASP.NET Core Web App (MVC)](./examples/FeatureFlagDemo) * [Blazor Server App](./examples/BlazorServerApp) -* [ASP.NET Core Web App with Feature Flag Telemetry](./examples/EvaluationDataToApplicationInsights) +* [ASP.NET Core Web App with Variants and Telemetry](./examples/VariantAndTelemetryDemo) * [ASP.NET Core Web App with Variant Service](./examples/VariantServiceDemo) ## Contributing diff --git a/examples/EvaluationDataToApplicationInsights/HttpContextTargetingContextAccessor.cs b/examples/EvaluationDataToApplicationInsights/HttpContextTargetingContextAccessor.cs deleted file mode 100644 index eeaa16b1..00000000 --- a/examples/EvaluationDataToApplicationInsights/HttpContextTargetingContextAccessor.cs +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT license. -// -using Microsoft.FeatureManagement.FeatureFilters; - -namespace EvaluationDataToApplicationInsights -{ - /// - /// Provides an implementation of that creates a targeting context using info from the current HTTP request. - /// - public class HttpContextTargetingContextAccessor : ITargetingContextAccessor - { - private const string TargetingContextLookup = "HttpContextTargetingContextAccessor.TargetingContext"; - private readonly IHttpContextAccessor _httpContextAccessor; - - public HttpContextTargetingContextAccessor(IHttpContextAccessor httpContextAccessor) - { - _httpContextAccessor = httpContextAccessor ?? throw new ArgumentNullException(nameof(httpContextAccessor)); - } - - public ValueTask GetContextAsync() - { - HttpContext httpContext = _httpContextAccessor.HttpContext; - - // - // Try cache lookup - if (httpContext.Items.TryGetValue(TargetingContextLookup, out object value)) - { - return new ValueTask((TargetingContext)value); - } - - // - // Grab username from cookie - string username = httpContext.Request.Cookies["username"]; - - var groups = new List(); - - // - // Build targeting context based on user info - var targetingContext = new TargetingContext - { - UserId = username, - Groups = groups - }; - - // - // Cache for subsequent lookup - httpContext.Items[TargetingContextLookup] = targetingContext; - - return new ValueTask(targetingContext); - } - } -} diff --git a/examples/EvaluationDataToApplicationInsights/Pages/RandomizeUser.cshtml b/examples/EvaluationDataToApplicationInsights/Pages/RandomizeUser.cshtml deleted file mode 100644 index fa29a988..00000000 --- a/examples/EvaluationDataToApplicationInsights/Pages/RandomizeUser.cshtml +++ /dev/null @@ -1,4 +0,0 @@ -@page -@model EvaluationDataToApplicationInsights.Pages.RandomizeUserModel -@{ -} diff --git a/examples/EvaluationDataToApplicationInsights/Pages/RandomizeUser.cshtml.cs b/examples/EvaluationDataToApplicationInsights/Pages/RandomizeUser.cshtml.cs deleted file mode 100644 index dad3744d..00000000 --- a/examples/EvaluationDataToApplicationInsights/Pages/RandomizeUser.cshtml.cs +++ /dev/null @@ -1,18 +0,0 @@ -using Microsoft.AspNetCore.Mvc; -using Microsoft.AspNetCore.Mvc.RazorPages; - -namespace EvaluationDataToApplicationInsights.Pages -{ - public class RandomizeUserModel : PageModel - { - public IActionResult OnGet() - { - // Clear Application Insights cookies and generate new username - Response.Cookies.Delete("ai_user"); - Response.Cookies.Delete("ai_session"); - Response.Cookies.Append("username", Random.Shared.Next().ToString()); - - return RedirectToPage("/Index"); - } - } -} diff --git a/examples/EvaluationDataToApplicationInsights/Pages/Checkout.cshtml b/examples/VariantAndTelemetryDemo/Pages/Checkout.cshtml similarity index 100% rename from examples/EvaluationDataToApplicationInsights/Pages/Checkout.cshtml rename to examples/VariantAndTelemetryDemo/Pages/Checkout.cshtml diff --git a/examples/EvaluationDataToApplicationInsights/Pages/Checkout.cshtml.cs b/examples/VariantAndTelemetryDemo/Pages/Checkout.cshtml.cs similarity index 67% rename from examples/EvaluationDataToApplicationInsights/Pages/Checkout.cshtml.cs rename to examples/VariantAndTelemetryDemo/Pages/Checkout.cshtml.cs index ceaaef99..ea8a9104 100644 --- a/examples/EvaluationDataToApplicationInsights/Pages/Checkout.cshtml.cs +++ b/examples/VariantAndTelemetryDemo/Pages/Checkout.cshtml.cs @@ -1,6 +1,6 @@ using Microsoft.AspNetCore.Mvc.RazorPages; -namespace EvaluationDataToApplicationInsights.Pages +namespace VariantAndTelemetryDemo.Pages { public class CheckoutModel : PageModel { diff --git a/examples/EvaluationDataToApplicationInsights/Pages/Error.cshtml b/examples/VariantAndTelemetryDemo/Pages/Error.cshtml similarity index 100% rename from examples/EvaluationDataToApplicationInsights/Pages/Error.cshtml rename to examples/VariantAndTelemetryDemo/Pages/Error.cshtml diff --git a/examples/EvaluationDataToApplicationInsights/Pages/Error.cshtml.cs b/examples/VariantAndTelemetryDemo/Pages/Error.cshtml.cs similarity index 92% rename from examples/EvaluationDataToApplicationInsights/Pages/Error.cshtml.cs rename to examples/VariantAndTelemetryDemo/Pages/Error.cshtml.cs index f20de344..4aba79bc 100644 --- a/examples/EvaluationDataToApplicationInsights/Pages/Error.cshtml.cs +++ b/examples/VariantAndTelemetryDemo/Pages/Error.cshtml.cs @@ -2,7 +2,7 @@ using Microsoft.AspNetCore.Mvc.RazorPages; using System.Diagnostics; -namespace EvaluationDataToApplicationInsights.Pages +namespace VariantAndTelemetryDemo.Pages { [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] [IgnoreAntiforgeryToken] diff --git a/examples/EvaluationDataToApplicationInsights/Pages/Index.cshtml b/examples/VariantAndTelemetryDemo/Pages/Index.cshtml similarity index 100% rename from examples/EvaluationDataToApplicationInsights/Pages/Index.cshtml rename to examples/VariantAndTelemetryDemo/Pages/Index.cshtml diff --git a/examples/EvaluationDataToApplicationInsights/Pages/Index.cshtml.cs b/examples/VariantAndTelemetryDemo/Pages/Index.cshtml.cs similarity index 94% rename from examples/EvaluationDataToApplicationInsights/Pages/Index.cshtml.cs rename to examples/VariantAndTelemetryDemo/Pages/Index.cshtml.cs index 0fbcf0b7..07b1d300 100644 --- a/examples/EvaluationDataToApplicationInsights/Pages/Index.cshtml.cs +++ b/examples/VariantAndTelemetryDemo/Pages/Index.cshtml.cs @@ -3,7 +3,7 @@ using Microsoft.AspNetCore.Mvc.RazorPages; using Microsoft.FeatureManagement; -namespace EvaluationDataToApplicationInsights.Pages +namespace VariantAndTelemetryDemo.Pages { public class IndexModel : PageModel { @@ -22,7 +22,7 @@ public IndexModel( public async Task OnGet() { - Username = Request.Cookies["username"]; + Username = HttpContext.User.Identity.Name; if (string.IsNullOrEmpty(Username)) { diff --git a/examples/VariantAndTelemetryDemo/Pages/RandomizeUser.cshtml b/examples/VariantAndTelemetryDemo/Pages/RandomizeUser.cshtml new file mode 100644 index 00000000..8aa505b1 --- /dev/null +++ b/examples/VariantAndTelemetryDemo/Pages/RandomizeUser.cshtml @@ -0,0 +1,4 @@ +@page +@model VariantAndTelemetryDemo.Pages.RandomizeUserModel +@{ +} diff --git a/examples/VariantAndTelemetryDemo/Pages/RandomizeUser.cshtml.cs b/examples/VariantAndTelemetryDemo/Pages/RandomizeUser.cshtml.cs new file mode 100644 index 00000000..781339d1 --- /dev/null +++ b/examples/VariantAndTelemetryDemo/Pages/RandomizeUser.cshtml.cs @@ -0,0 +1,30 @@ +using Microsoft.AspNetCore.Authentication; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc.RazorPages; +using System.Security.Claims; + +namespace VariantAndTelemetryDemo.Pages +{ + public class RandomizeUserModel : PageModel + { + public IActionResult OnGet() + { + // Clear Application Insights cookies and + Response.Cookies.Delete("ai_user"); + Response.Cookies.Delete("ai_session"); + + // Generate new user claim + var claims = new List + { + new Claim(ClaimTypes.Name, Random.Shared.Next().ToString()) + }; + + var identity = new ClaimsIdentity(claims, "CookieAuth"); + var principal = new ClaimsPrincipal(identity); + + HttpContext.SignInAsync("CookieAuth", principal); + + return RedirectToPage("/Index"); + } + } +} diff --git a/examples/EvaluationDataToApplicationInsights/Pages/Shared/_Layout.cshtml b/examples/VariantAndTelemetryDemo/Pages/Shared/_Layout.cshtml similarity index 85% rename from examples/EvaluationDataToApplicationInsights/Pages/Shared/_Layout.cshtml rename to examples/VariantAndTelemetryDemo/Pages/Shared/_Layout.cshtml index c8d3f799..365b135c 100644 --- a/examples/EvaluationDataToApplicationInsights/Pages/Shared/_Layout.cshtml +++ b/examples/VariantAndTelemetryDemo/Pages/Shared/_Layout.cshtml @@ -6,10 +6,10 @@ - @ViewData["Title"] - EvaluationDataToApplicationInsights + @ViewData["Title"] - VariantAndTelemetryDemo - + @Html.Raw(JavaScriptSnippet.FullScript) @@ -20,7 +20,7 @@