using System.Net.Http.Headers; namespace Biskilog_Accounting.Client.Layouts { public partial class MainLayout { protected override async Task OnInitializedAsync() { //Checks if user token is set else redirect user to login page if (!await m_tokenService.IsTokenSet()) { m_navigationManager.NavigateTo("/login"); } else { string token = await m_tokenService.GetToken(); var authHeader = new AuthenticationHeaderValue("Bearer", token.Substring(6).Trim()); m_http.DefaultRequestHeaders.Authorization = authHeader; } return; } } }