Skip to content

Instantly share code, notes, and snippets.

View hasmukhlalpatel's full-sized avatar

Hasmukh Patel hasmukhlalpatel

View GitHub Profile
@hasmukhlalpatel
hasmukhlalpatel / Function1.cs
Last active May 29, 2025 19:37
Isolated Function AI logger issue - LogicalCallContext AsyncLocal
using System.Net;
using Microsoft.Azure.Functions.Worker;
using Microsoft.Azure.Functions.Worker.Http;
using Microsoft.Extensions.Logging;
namespace IsolatedFunctionApp1
{
public class Function1
{
private readonly ILogger _logger;
@hasmukhlalpatel
hasmukhlalpatel / readme.md
Created October 3, 2022 20:12
Comparison between Application Gateway, Front Door, Load Balancer and Traffic Manager
Service Global/Regional type of traffic
Application Gateway Global HTTP i.e. L7
Front Door Global non-HTTP i.e. L4
Load Balancer Regional HTTP i.e. L7
Traffic Manager Regional non-HTTP i.e. L4
@hasmukhlalpatel
hasmukhlalpatel / ClientTokenAuthenticationHandler.cs
Created August 4, 2021 08:53
Validate Custom client JWT on Dotnet core
using System;
using System.IdentityModel.Tokens.Jwt;
using System.Text.Encodings.Web;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authentication;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using Microsoft.Extensions.Primitives;
using Microsoft.IdentityModel.Tokens;
@hasmukhlalpatel
hasmukhlalpatel / readme.md
Last active August 29, 2020 16:08
Managing the global packages, cache, and temp folders

Whenever you install, update, or restore a package, NuGet manages packages and package information in several folders outside of your project structure:

MANAGING THE GLOBAL PACKAGES, CACHE, AND TEMP FOLDERS

global‑packages

The global-packages folder is where NuGet installs any downloaded package. Each package is fully expanded into a subfolder that matches the package identifier and version number. Projects using the PackageReference format always use packages directly from this folder. When using the packages.config, packages are installed to the global-packages folder, then copied into the project's packages folder.

  • Windows: %userprofile%.nuget\packages
  • Mac/Linux: ~/.nuget/packages

Override using the NUGET_PACKAGES environment variable, the globalPackagesFolder or repositoryPath configuration settings (when using PackageReference and packages.config, respectively), or the RestorePackagesPath MSBuild property (MSBuild only). The environment variable takes precedence over the configuration set

@hasmukhlalpatel
hasmukhlalpatel / readme.md
Last active August 29, 2020 16:07
To force ./packages folder for Solution

To force download of packages folder to be a child of the solution folder for .NET Core projects, follow these steps :

  1. Create a NuGet.Config file in the same directory as the .sln file.

  2. Copy the following contents into the NuGet.Config file:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <config>
 
@hasmukhlalpatel
hasmukhlalpatel / RateLimitAndPreventUnathorizedIPAccessFilter.cs
Created August 13, 2020 21:56
RateLimit and PreventUnathorizedIP Access Filter
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
using System.Web;
using System.Web.Http.Filters;
@hasmukhlalpatel
hasmukhlalpatel / HttpStatusCode.txt
Last active June 3, 2021 10:08
HttpStatusCodes
Http Response Codes Summary
Continue 100 = Equivalent to HTTP status 100. Continue indicates that the client can continue with its request.
SwitchingProtocols 101 = Equivalent to HTTP status 101. SwitchingProtocols indicates that the protocol version or protocol is being changed.
Processing 102 = Equivalent to HTTP status 102. Processing indicates that the server has accepted the complete request but hasn't completed it yet.
EarlyHints 103 = Equivalent to HTTP status 103. EarlyHints indicates to the client that the server is likely to send a final response with the header fields included in the informational response.
OK 200: Everything worked as expected.
OK 200 = Equivalent to HTTP status 200. OK indicates that the request succeeded and that the requested information is in the response. This is the most common status code to receive.
@hasmukhlalpatel
hasmukhlalpatel / tryTaskAsyncAwait.cs
Created July 22, 2020 11:44
See the differences between Async/Await call and returning task. Copy this code and paste into https://sharplab.io/
//Copy this code and paste into https://sharplab.io/
using System;
using System.Threading.Tasks;
public class C {
int id =0;
public void M() {
}
@hasmukhlalpatel
hasmukhlalpatel / EnumSample.cs
Created July 22, 2020 10:36
c# Enum Sample
using System;
using System.ComponentModel;
using System.Reflection;
using System.Collections.Generic;
using System.Linq;
public class Program
{
[Flags]
@hasmukhlalpatel
hasmukhlalpatel / AsyncHelper.cs
Created July 21, 2020 07:36
C# Dotnet AsyncHelpers : Make an aync method to Sync and Sync. Method to Async
using System;
using System.Threading;
using System.Threading.Tasks;
namespace App.Utilities.Extensions
{
public static class AsyncHelper
{
private static readonly TaskFactory _internalTaskFactory = new TaskFactory(CancellationToken.None, TaskCreationOptions.None, TaskContinuationOptions.None, TaskScheduler.Default);