zoukankan      html  css  js  c++  java
  • .net core2.1 配置

    services.AddControllersWithViews().AddNewtonsoftJson();

    Install-Package Microsoft.AspNetCore.Mvc.NewtonsoftJson -Version 3.1.3

    ASPNETCORE_ENVIRONMENT

    Development(开发)
    Staging(预演)
    Production(生产)

    var builder = new ConfigurationBuilder()
    .SetBasePath(env.ContentRootPath)
    .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
    .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true)
    .AddEnvironmentVariables();

    • IsDevelopment()
    • IsStaging()
    • IsProduction()
    • IsEnvironment()

    Configuration = builder.Build();

    var defaultTest = Configuration["Logging:LogLevel:Default"];

    var environment = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT");
    var isDevelopment = environment == EnvironmentName.Development;

    https://docs.microsoft.com/zh-tw/aspnet/core/fundamentals/environments?view=aspnetcore-2.1

     https://andrewlock.net/why-isnt-my-asp-net-core-environment-specific-configuration-loading/

    https://dotnetcoretutorials.com/2017/05/03/environments-asp-net-core/

     https://stackoverflow.com/questions/46444981/setting-environment-variables-in-net-core-2-0

    https://pascalnaber.wordpress.com/2017/11/29/handling-settings-and-environment-variables-of-your-net-core-2-application-hosted-in-a-docker-container-during-development-and-on-kubernetes-helm-to-the-resque/

    export ASPNETCORE_ENVIRONMENT=development

    http://www.cnblogs.com/xishuai/p/asp-net-core-set-hosting-environment-with-publish.html

    https://blog.csdn.net/sD7O95O/article/details/78096359

    https://stackexchange.github.io/StackExchange.Redis/Timeouts.html

    How to configure this setting:

    • In ASP.NET, use the “minIoThreads” configuration setting under the <processModel> configuration element in machine.config. According to Microsoft, you can’t change this value per site by editing your web.config (even when you could do it in the past), so the value that you choose here is the value that all your .NET sites will use. Please note that you don’t need to add every property if you put autoConfig in false, just putting autoConfig=”false” and overriding the value is enough:
    <processModel autoConfig="false" minIoThreads="250" />
    

    Important Note: the value specified in this configuration element is a per-core setting. For example, if you have a 4 core machine and want your minIOThreads setting to be 200 at runtime, you would use <processModel minIoThreads="50"/>.

    export ASPNETCORE_ENVIRONMENT=development

     [ServiceFilter(typeof(ValidateReCaptchaAttribute))]

     services.AddScoped<ValidateReCaptchaAttribute>();

    Request.Cookies[".AspNetCore.Session"]

    HttpContext.Session.Id

  • 相关阅读:
    在ASP.NET Core中怎么使用HttpContext.Current (转载)
    如何在.Net Core 2.0 App中读取appsettings.json
    ASP.NET CORE MVC 2.0 如何在Filter中使用依赖注入来读取AppSettings,及.NET Core控制台项目中读取AppSettings
    linux中shell变量$#,$@,$0,$1,$2的含义解释<转>
    ijkplayer阅读学习笔记之从代码上看播放流程
    ubuntu命令整理中
    Android SDK Android NDK Android Studio 官方下载地址<转>
    Ubuntu启动 卡在checking battery state 解决方案
    解决 ffmpeg 在avformat_find_stream_info执行时间太长
    ijkplayer阅读笔记系列<转>
  • 原文地址:https://www.cnblogs.com/zwei1121/p/9792220.html
Copyright © 2011-2022 走看看