Skip to content

Commit

Permalink
chore: Update Index.cshtml to include environment information
Browse files Browse the repository at this point in the history
  • Loading branch information
MSFTJim authored Aug 9, 2024
1 parent 7c3c22c commit 82b9d9c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
8 changes: 6 additions & 2 deletions frontend/Pages/Index.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,12 @@
</div>

<environment include="Development">
<div>Environment is Development</div>
<div>Environment is Development</div>
</environment>

<environment exclude="Development">
<div>Environment is NOT Development</div>
<div>Environment is NOT Development</div>
</environment>

<div> Environment: @Model.envEnvironment </div>
<div> API Url: @Model.envAPIProductionUrl </div>
9 changes: 8 additions & 1 deletion frontend/Pages/Index.cshtml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,28 @@
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;

namespace frontend.Pages
{
public class IndexModel : PageModel
{
private readonly ILogger<IndexModel> _logger;
private readonly IConfiguration _config;
public string envEnvironment { get; set; }
public string envAPIProductionUrl { get; set; }

public IndexModel(ILogger<IndexModel> logger)
public IndexModel(ILogger<IndexModel> logger, IConfiguration config)
{
_logger = logger;
_config = config;
}

public void OnGet()
{
envEnvironment = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT");
envAPIProductionUrl = _config["APIProductionUrl"];

}
}
Expand Down

0 comments on commit 82b9d9c

Please sign in to comment.