Sep 30, 2019

ASP.NET simulating multihreading - supporting concurrent non-blocking Ajax : RePost

http://johnculviner.com/asp-net-concurrent-ajax-requests-and-session-state-blocking/

May 28, 2019

RePost: Serilog with StructureMap - ASP.Net Core 2.1


https://andydote.co.uk/2017/07/28/serilog-context-with-structuremap-and-simpleinjector/

https://carlos.mendible.com/2019/01/14/updated-step-step-serilog-asp-net-core/

https://stackify.com/serilog-tutorial-net-logging/


Required NuGet:

Serilog.AspNetCore
Serilog.Extensions.Logging
Serilog.Sinks.File

Example of Program.cs

public class Program
    {
        public static void Main(string[] args)
        {
            Log.Logger = new LoggerConfiguration()
                            .Enrich.FromLogContext()
                            .MinimumLevel.Error()
                            .WriteTo.File("log.txt", rollingInterval: RollingInterval.Day,rollOnFileSizeLimit:true,fileSizeLimitBytes:10000000)
                            .CreateLogger();
            try
            {
                BuildWebHost(args).Run();
            }
            finally
            {
                Log.CloseAndFlush();
            }
        }
        public static IWebHost BuildWebHost(string[] args) =>
            WebHost.CreateDefaultBuilder(args)
                .UseSerilog()
                .UseStartup<Startup>()
                .Build();
    }

 Startup.cs:

public IServiceProvider ConfigureServices(IServiceCollection services)
        {
         
            ....
            return ConfigureIoc(services);
        }
public IServiceProvider ConfigureIoc(IServiceCollection services)
        {
            var container = new Container(config =>
            {
                config.Scan(_ =>
                {
                    _.AssemblyContainingType(typeof(Startup));
                    _.AssembliesAndExecutablesFromApplicationBaseDirectory();
                    _.WithDefaultConventions();
                });
                config.For<ILogger>().Use(context => Log.ForContext(context.ParentType));     
                config.Populate(services);
            });
            return container.GetInstance<IServiceProvider>();
        }

How to use:


private readonly ILogger<MyClass> _logger = null;     
        public MyClass(
            ILogger<MyClass> logger         
            )
        {
            _logger = logger; 

Apr 19, 2019

Bootstrap 4 checkbox change jquery javascript

        isCreditCardPaymentSelector: "input[name = 'IsCreditCardPayment']",
        isCreditCardPaymentIdSelector: "input[name='IsCreditCardPayment'][type='hidden']",

form.find(options.isCreditCardPaymentSelector).removeAttr('checked');        form.find(options.isCreditCardPaymentSelector).parent('label').removeClass('active');
form.find(options.isCreditCardPaymentIdSelector).val(false);

Feb 8, 2019

RePost: Git concepts

Very good point about Git architecture.

https://stackoverflow.com/questions/292357/what-is-the-difference-between-git-pull-and-git-fetch

Git was designed to support a more distributed model with no need for a central repository (though you can certainly use one if you like). Also git was designed so that the client and the "server" don't need to be online at the same time. Git was designed so that people on an unreliable link could exchange code via email, even. It is possible to work completely disconnected and burn a CD to exchange code via git.
In order to support this model git maintains a local repository with your code and also an additional local repository that mirrors the state of the remote repository. By keeping a copy of the remote repository locally, git can figure out the changes needed even when the remote repository is not reachable. Later when you need to send the changes to someone else, git can transfer them as a set of changes from a point in time known to the remote repository.
git fetch is the command that says "bring my local copy of the remote repository up to date."
git pull says "bring the changes in the remote repository to where I keep my own code."
Normally git pull does this by doing a git fetch to bring the local copy of the remote repository up to date, and then merging the changes into your own code repository and possibly your working copy.
The take away is to keep in mind that there are often at least three copies of a project on your workstation. One copy is your own repository with your own commit history. The second copy is your working copy where you are editing and building. The third copy is your local "cached" copy of a remote repository.