Websites are stateless. There is no load app event for a user, just a web request. You can use cookies to maintain state.
You can add the code to the pages that require this check, or use middleware to check all requests.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
When the Razor page app loads for a user, need to check to see if the person is in a SQL table, no UI is needed during this process. This app is only accessible after the user is logged into our internal network behind a firewall. I already have access to their user id. I only need to verify that they are in a table, no UI is needed. If they are in the table, I need to send them to a main menu in the app. If they are not, another page should be show.
This is how I getting the user ID, which works when the user presses ‘Button’ on the initial Razor.
I just need to do this in the start-up of the Razor Page / Application without showing the UI. Maybe in the Startup.CS class or in some load event. Maybe in the Main function in Programs.cs class. Any ideas?
Razor page code.
private async Task GetPage()
{
{
List<Claim> claims = new List<Claim>();
string useridWinBase = System.Security.Principal.WindowsIdentity.GetCurrent().Name;
string useridWin = useridWinBase.Replace("DomainABC\\", "");
// this is where the check to the database table occur
Credentials.User user = this.authService.LoginDB(Configuration, useridWin);
Websites are stateless. There is no load app event for a user, just a web request. You can use cookies to maintain state.
You can add the code to the pages that require this check, or use middleware to check all requests.