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.Collections; | |
| using System.Collections.Generic; | |
| using System.Linq; | |
| using System.Linq.Expressions; | |
| using System.Reflection; | |
| namespace Titan.ODataClient | |
| { | |
| public class CustomLinqProvider<T> : IQueryable<T>, IQueryProvider |
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 ValidateMe : IValidatableObject | |
| { | |
| [Required] | |
| public bool Enable { get; set; } | |
| [Range(1, 5)] | |
| public int Prop1 { get; set; } | |
| [Range(1, 5)] | |
| public int Prop2 { get; set; } |
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
| _contextAccessor?.HttpContext is null | |
| https://docs.microsoft.com/en-us/aspnet/core/fundamentals/websockets?view=aspnetcore-3.1#iisiis-express-support | |
| -- | |
| If the HttpContext null-reference exception happens after deployment to Azure App Services or IIS, you might have forgotten to enable WebSockets. | |
| Here is the deal: | |
| If the app runs on Windows with IIS: WebSockets must be enabled. |
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
| <%@ Page Language="C#" AutoEventWireup="true" ClassName="Default" %> | |
| <% | |
| var url = string.Format("http{0}://{1}{2}", (Request.IsSecureConnection) ? "s" : "", Request.Url.Host, Page.ResolveUrl("relativeUrl")); | |
| var headers = String.Empty; | |
| foreach (var key in Request.Headers.AllKeys) | |
| headers += key + "=" + Request.Headers[key] + "<BR/>"; | |
| var requestData = ""; | |
| requestData+=(string.Format("scheme={0}",Request.Url.Scheme)+ "<BR/>"); | |
| requestData+=(string.Format("Host={0}",Request.Url.Host)+ "<BR/>"); |
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 interface IJwtUtils | |
| { | |
| public string GenerateToken(ClaimsIdentity claimsIdentity, AuthRequestContext requestContext, | |
| out long expiresIn, | |
| DateTime? issuedAt = null, DateTime? notBefore = null, DateTime? expires = null, double defaultExpiryMinutes = 30); | |
| public bool ValidateToken(string token, AuthRequestContext requestContext); | |
| } | |
| public class JwtUtils : IJwtUtils | |
| { |
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
| //Get JWKS url from https://{authserver}/.well-known/openid-configuration | |
| //e.g. : https://demo.identityserver.io/.well-known/openid-configuration | |
| /* | |
| //get public keys (e "Exponent" & n "Modulus") values "https://{authserver}/.well-known/openid-configuration/jwks" | |
| //e.g. {"keys":[{"kty":..., "use":..., "kid":... "e":"AQAB", "n":"w7Zdfmece8iaB0kiTY...", "alg":"RS256" } ]} | |
| //e.g. "https://demo.identityserver.io/.well-known/openid-configuration/jwks" | |
| */ | |
| public static void ValidateToken(string token){ | |
| string tokenStr = "eyJraWQiOiIxZTlnZGs3IiwiYWxnIjoiUlMyNTYifQ.ewogImlzcyI6ICJodHRwOi8vc2VydmVyLmV4YW1wbGUuY29tIiwKICJzdWIiOiAiMjQ4Mjg5NzYxMDAxIiwKICJhdWQiOiAiczZCaGRSa3F0MyIsCiAibm9uY2UiOiAibi0wUzZfV3pBMk1qIiwKICJleHAiOiAxMzExMjgxOTcwLAogImlhdCI6IDEzMTEyODA5NzAsCiAiY19oYXNoIjogIkxEa3RLZG9RYWszUGswY25YeENsdEEiCn0.XW6uhdrkBgcGx6zVIrCiROpWURs-4goO1sKA4m9jhJIImiGg5muPUcNegx6sSv43c5DSn37sxCRrDZZm4ZPBKKgtYASMcE20SDgvYJdJS0cyuFw7Ijp_7WnIjcrl6B5cmoM6ylCvsLMwkoQAxVublMwH10oAxjzD6NEFsu9nipkszWhsPePf_rM4eMpkmCbTzume-fzZIi5V |
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.Collections.Generic; | |
| using Microsoft.AspNetCore.Components; | |
| namespace MyApp.Components | |
| { | |
| public abstract class BsComponentBase: ComponentBase | |
| { | |
| protected const string StylesBtnPrimary = "btn-primary"; | |
| protected const string StylesBtnSecondary = "btn-secondary"; | |
| protected const string StylesBtnSuccess = "btn-success"; |
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.Collections.Generic; | |
| using Microsoft.AspNetCore.Components; | |
| namespace MyApp.Components | |
| { | |
| public abstract class BsComponentBase: ComponentBase | |
| { | |
| protected const string StylesBtnPrimary = "btn-primary"; | |
| protected const string StylesBtnSecondary = "btn-secondary"; | |
| protected const string StylesBtnSuccess = "btn-success"; |
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
| var options = new JsonSerializerOptions | |
| { | |
| PropertyNamingPolicy = JsonNamingPolicy.CamelCase, | |
| Converters = { new StringToIntJsonConverter(), new StringToDecimalJsonConverter(), new JsonStringEnumConverter() }, | |
| IgnoreNullValues = true | |
| }; | |
| var json = "{\"firstname\":\"John\",\"lastname\":\"Smith\"}"; | |
| var person = JsonSerializer.Parse<Person>(json, 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
| using HpBlazor.Components.Shared; | |
| using Microsoft.AspNetCore.Components; | |
| using Microsoft.AspNetCore.Components.Routing; | |
| using System; | |
| using System.Collections.Generic; | |
| using System.Reflection; | |
| using System.Threading.Tasks; | |
| namespace BlazorApp1.Core | |
| { |