This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public async Task<T> GetAsync<T>(string url) | |
| { | |
| if (string.IsNullOrWhiteSpace(url)) | |
| return default; | |
| var client = _httpClientFactory.CreateClient("MyApiClient"); | |
| var tokenResult = await _accessTokenProvider.RequestAccessToken(); | |
| if (tokenResult.TryGetToken(out var token)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| options.TokenValidationParameters = new TokenValidationParameters() { | |
| ValidateIssuerSigningKey = true, | |
| ValidateIssuer = true, | |
| ValidateAudience = true, | |
| ValidIssuer = Configuration["Authentication:Jwt:Issuer"], | |
| ValidAudience = Configuration["Authentication:Jwt:Audience"], | |
| IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(Configuration["Authentication:Jwt:IssuerSigningKey"])) | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| private const int DefaultBufferSize = 4096; | |
| private protected async Task<IActionResult> ReadRangedContentAsync(Func<byte[], Task<Result>> readCallback) | |
| { | |
| if (!Request.HasFormContentType || | |
| !MediaTypeHeaderValue.TryParse(Request.ContentType, out var contentType) || | |
| !contentType.Boundary.HasValue || | |
| !Request.Headers.TryGetValue(HeaderNames.ContentRange, out var contentRangeValues) || | |
| !ContentRangeHeaderValue.TryParse(contentRangeValues.First(), out var contentRange) || | |
| !contentRange.HasRange) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System; | |
| using System.Threading; | |
| using System.Threading.Tasks; | |
| using Microsoft.Extensions.DependencyInjection; | |
| using Microsoft.Extensions.Hosting; | |
| using Microsoft.Extensions.Logging; | |
| using Microsoft.EntityFrameworkCore; | |
| namespace API.Services | |
| { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class ProcessIssuersJobSetupWithoutCron : IConfigureOptions<QuartzOptions> | |
| { | |
| public void Configure(QuartzOptions options) | |
| { | |
| var processIssuersJobKey = JobKey.Create("ProcessIssuersJob"); | |
| options | |
| .AddJob<ProcessIssuersJob>(jobBuilder => jobBuilder.WithIdentity(processIssuersJobKey)) | |
| .AddTrigger(trigger => | |
| trigger |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| builder.Services.AddAuthentication(options => | |
| { | |
| options.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme; | |
| }) | |
| .AddCookie("OktaCookies", options => | |
| { | |
| options.LoginPath = new PathString("/Account/SignIn"); | |
| options.Cookie.Name = "OktaCookies"; | |
| }) | |
| .AddCookie("EntraCookies", options => |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| services.AddAuthentication() | |
| .AddMicrosoftAccount(options => | |
| { | |
| IConfigurationSection microsoftAuthNSection = configuration.GetSection("Authentication:Microsoft"); | |
| options.ClientId = microsoftAuthNSection["ClientId"]; | |
| options.ClientSecret = microsoftAuthNSection["ClientSecret"]; | |
| options.CallbackPath = new PathString("/Identity/Account/MicrosoftExternalAccountCallBack"); | |
| options.AccessDeniedPath = new PathString("/Identity/Account/Login"); | |
| options.SaveTokens = true; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using Microsoft.AspNetCore.SignalR; | |
| namespace SignalRTest | |
| { | |
| public class MyHub : Hub | |
| { | |
| // This dictionary could map user connections to active timers if needed for multiple users | |
| private static readonly Dictionary<string, CancellationTokenSource> UserTimers = new Dictionary<string, CancellationTokenSource>(); | |
| private static readonly object UserTimersLock = new object(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @code { | |
| [Inject] | |
| private IJSRuntime JSRuntime { get; set; } | |
| protected override async Task OnAfterRenderAsync(bool firstRender) | |
| { | |
| if (firstRender) | |
| { | |
| foreach (var anData in ListOfMyData) | |
| { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| RemoteEndpointMessageProperty remoteEndpoint = OperationContext.Current.IncomingMessageProperties[RemoteEndpointMessageProperty.Name] as RemoteEndpointMessageProperty; | |
| if (remoteEndpoint != null) | |
| { | |
| string clientIPAddress = remoteEndpoint.Address; | |
| int clientPort = remoteEndpoint.Port; | |
| } | |
| else | |
| { | |
| Console.WriteLine("Can't get info from remote endpoint"); |