Skip to content

Instantly share code, notes, and snippets.

@ankitvijay
ankitvijay / Assembly2: SameNamespaceName.Class2
Last active January 21, 2018 11:42
Extern alias example 2
using System;
namespace SameNamespaceName
{
public class Class2
{
public static void MethodB()
{
var assemblyame = System.Reflection.Assembly.GetExecutingAssembly().GetName().Name;
Console.WriteLine($"Assemble Name: {assemblyame}");
@ankitvijay
ankitvijay / Program.cs
Created January 21, 2018 11:41
Extern alias example 3
extern alias assembly1;
namespace NamespaceAliasExample
{
public class Program
{
static void Main(string[] args)
{
assembly1::SameNamespaceName.Class1.MethodA();
SameNamespaceName.Class2.MethodB();
@ankitvijay
ankitvijay / web.config
Last active April 20, 2018 22:57
localAppSettings.config Example 1
<appSettings file="localAppSettings.config">
<add key="dbConnectionString" value="sourceControlConnectionString"/>
<add key="someRandomApplicationSetting" value="sourceControlApplicationSetting"/>
</appSettings>
@ankitvijay
ankitvijay / localAppSettings.config
Last active April 20, 2018 22:30
localAppSettings.config Example 2
<appSettings>
<add key="dbConnectionString" value="localMachineConnectionString"/>
</appSettings>
@ankitvijay
ankitvijay / Program.cs
Created May 17, 2018 20:46
HttpClient Example 1
using (var httpClient = new HttpClient())
{
await httpClient.GetAsync(new Uri("http://bing.com"));
}
@ankitvijay
ankitvijay / Program.cs
Last active May 17, 2018 20:49
HttpClient Example 2
namespace HttpClientTest
{
using System;
using System.Net.Http;
class Program
{
private static readonly int _connections = 1000;
private static readonly HttpClient _httpClient = new HttpClient();
@ankitvijay
ankitvijay / .gitignore
Created December 27, 2018 20:29
Gitignore file to ignore the local appSettings
# Ignore local appSettings
appSettings.Local.json
{
"ConnectionStrings": {
"DefaultConnection": "Server=MY_MACHINE_NAME;Database=MY_LOCAL_DB;Trusted_Connection=True;MultipleActiveResultSets=true"
}
}
@ankitvijay
ankitvijay / Startup.cs
Created December 27, 2018 21:31
Startup - App local settings
if (env.IsDevelopment() || env.IsEnvironment("Local"))
{
app.UseDeveloperExceptionPage();
}
@ankitvijay
ankitvijay / AlwaysOn.ps
Last active June 15, 2023 10:33
IIS Background Worker Setting
## IIS WebAdmin Module
Import-Module WebAdministration
$AppPoolInstance = Get-Item IIS:\AppPools\$AppPool
Write-Output "Set Site PreLoadEnabled to true"
Set-ItemProperty IIS:\Sites\$Site -name applicationDefaults.preloadEnabled -value True
Write-Output "Set Recycling.periodicRestart.time = 0"
$AppPoolInstance.Recycling.periodicRestart.time = [TimeSpan]::Parse("0");