filter attribute that checks whether current connection is secured

using APS.net Core to mark all website pages working with https protocol
we will do this using IAuthorizationFilter.
and here is an example how we can do it.
/// <summary>
    /// Represents a filter attribute that checks whether current connection is secured and properly redirect if necessary
    /// </summary>
    public class HttpsRequirementAttribute : TypeFilterAttribute
    {
        #region Fields

        private readonly SslRequirement _sslRequirement;

        #endregion

        #region Ctor

        /// <summary>
        /// Create instance of the filter attribute
        /// </summary>
        /// <param name="sslRequirement">Whether the page should be secured</param>
        public HttpsRequirementAttribute(SslRequirement sslRequirement) : base(typeof(HttpsRequirementFilter))
        {
            this._sslRequirement = sslRequirement;
            this.Arguments = new object[] { sslRequirement };
        }

        #endregion

        #region Properties

        /// <summary>
        /// Gets a value indicating whether the page should be secured
        /// </summary>
        public SslRequirement SslRequirement => _sslRequirement;

        #endregion

        #region Nested filter

        /// <summary>
        /// Represents a filter confirming that checks whether current connection is secured and properly redirect if necessary
        /// </summary>
        private class HttpsRequirementFilter : IAuthorizationFilter
        {
            #region Fields

            private SslRequirement _sslRequirement;
            private readonly WebsiteSettings _websiteSettings;
            private readonly IWebHelper _webHelper;
            private readonly SecuritySettings _securitySettings;

            #endregion

            #region Ctor

            public HttpsRequirementFilter(SslRequirement sslRequirement,
                WebsiteSettings websiteSettings,
                IWebHelper webHelper,
                SecuritySettings securitySettings)
            {
                this._sslRequirement = sslRequirement;
                this._websiteSettings = websiteSettings;
                this._webHelper = webHelper;
                this._securitySettings = securitySettings;
            }

            #endregion

            #region Utilities

            /// <summary>
            /// Check whether current connection is secured and properly redirect if necessary
            /// </summary>
            /// <param name="filterContext">Authorization filter context</param>
            /// <param name="useSsl">Whether the page should be secured</param>
            protected void RedirectRequest(AuthorizationFilterContext filterContext, bool useSsl)
            {
                //whether current connection is secured
                var currentConnectionSecured = _webHelper.IsCurrentConnectionSecured();

                //page should be secured, so redirect (permanent) to HTTPS version of page
                if (useSsl && !currentConnectionSecured && _websiteSettings.SslEnabled)
                    filterContext.Result = new RedirectResult(_webHelper.GetThisPageUrl(true, true), true);

                //page shouldn't be secured, so redirect (permanent) to HTTP version of page
                if (!useSsl && currentConnectionSecured)
                    filterContext.Result = new RedirectResult(_webHelper.GetThisPageUrl(true, false), true);
            }

            #endregion

            #region Methods

            /// <summary>
            /// Called early in the filter pipeline to confirm request is authorized
            /// </summary>
            /// <param name="filterContext">Authorization filter context</param>
            public void OnAuthorization(AuthorizationFilterContext filterContext)
            {
                if (filterContext == null)
                    throw new ArgumentNullException(nameof(filterContext));

                if (filterContext.HttpContext.Request == null)
                    return;

                //only in GET requests, otherwise the browser might not propagate the verb and request body correctly
                if (!filterContext.HttpContext.Request.Method.Equals(WebRequestMethods.Http.Get, StringComparison.InvariantCultureIgnoreCase))
                    return;

                if (!DataSettingsManager.DatabaseIsInstalled)
                    return;

                //check whether this filter has been overridden for the Action
                var actionFilter = filterContext.ActionDescriptor.FilterDescriptors
                    .Where(filterDescriptor => filterDescriptor.Scope == FilterScope.Action)
                    .Select(filterDescriptor => filterDescriptor.Filter).OfType<HttpsRequirementAttribute>().FirstOrDefault();

                var sslRequirement = actionFilter?.SslRequirement ?? _sslRequirement;

                //whether all pages will be forced to use SSL no matter of the passed value
                if (_securitySettings.ForceSslForAllPages)
                    sslRequirement = SslRequirement.Yes;

                switch (sslRequirement)
                {
                    case SslRequirement.Yes:
                        //redirect to HTTPS page
                        RedirectRequest(filterContext, true);
                        break;
                    case SslRequirement.No:
                        //redirect to HTTP page
                        RedirectRequest(filterContext, false);
                        break;
                    case SslRequirement.NoMatter:
                        //do nothing
                        break;
                    default:
                        throw new PasException("Not supported SslRequirement parameter");
                }
            }

            #endregion
        }

        #endregion
    }
this will do it.

Create, bind and register as service the specified configuration parameters

supposed you have a json file with a specific parameter and you want to fill a class with the specified properties.

and then register this object to the asp.net core service  collection
here is an example how to do it.
/// Create, bind and register as service the specified configuration parameters
        /// </summary>
        /// <typeparam name="TConfig">Configuration parameters</typeparam>
        /// <param name="services">Collection of service descriptors</param>
        /// <param name="configuration">Set of key/value application configuration properties</param>
        /// <returns>Instance of configuration parameters</returns>
        public static TConfig ConfigureStartupConfig<TConfig>(this IServiceCollection services, IConfiguration configuration) where TConfig : class, new()
        {
            if (services == null)
            {
                throw new ArgumentNullException(nameof(services));
            }

            if (configuration == null)
            {
                throw new ArgumentNullException(nameof(configuration));
            }

            //create instance of config
            TConfig config = new TConfig();

            //bind it to the appropriate section of configuration
            configuration.Bind(config);

            //and register it as a service
            services.AddSingleton(config);

            return config;
        }
this will do it.

Run exe file from console application

To run a .exe file using console application you need to do the following.

Process proc = new Process();
proc.StartInfo.WorkingDirectory = _filePath;
proc.StartInfo.FileName = _fileName;
proc.StartInfo.CreateNoWindow = false;
proc.Start();
proc.WaitForExit();

How to Authenticate from Azure

First you need to create a section in appsettings.json file
  "AzureAd": {
    "Instance": "https://login.microsoftonline.com/",
    "Domain": "Your Domain",
    "TenantId": "Your Tenant Id",
    "ClientId": "Your Client Id",
    "CallbackPath": "/signin-oidc"
  }
then I usually use extension method for the service collection
public static void AddApplicationAuthentication(this IServiceCollection services)
        {
            IConfiguration Configuration = services.BuildServiceProvider().GetRequiredService<IConfiguration>();

            services.Configure<CookiePolicyOptions>(options =>
            {
                // This lambda determines whether user consent for non-essential cookies is needed for a given request.
                options.CheckConsentNeeded = context => true;
                options.MinimumSameSitePolicy = SameSiteMode.None;
            });

            services.AddAuthentication(AzureADDefaults.AuthenticationScheme)
                .AddAzureAD(options => Configuration.Bind("AzureAd", options));
        }
this should do the trick

How to get months names based on Culture Info

To get the month names using a given Culture Info in a simple select list

var monthOfBirthValues = new List();
monthOfBirthValues.Add(new SelectListItem 


    Text = CultureInfo.GetCultureInfo("ar-KW").DateTimeFormat.GetMonthName(i), 
   Value = i.ToString(CultureInfo.InvariantCulture) 
});

filter attribute that checks whether current connection is secured

using APS.net Core to mark all website pages working with https protocol we will do this using IAuthorizationFilter. and here is an exampl...