zoukankan      html  css  js  c++  java
  • 在ASP.NET Core中使用多个环境

    官方文档地址

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

    launchSetting.json修改环境

    或者

     

    判断当前的环境

    自定义的环境使用env.IsEnvironment("Testing")判断

     cshtml中判断

    @{
        ViewData["Title"] = "Index";
        Layout = null;
    }
    //(include:包括)开发环境,多个环境中间用逗号隔开
    <environment include="Development">
      //*号代表所有文件
      <link rel="stylesheet" asp-href-include="~/css/*" />
    </environment>
    
    //(exclude:排除)不是开发环境
    <environment exclude="Development">
        <link rel="stylesheet" asp-href-include="~/css/site.min.css" asp-href-exclude="~/css/site.css" />
        //检查href中是否包含sr-only、position、absolute,没有则用asp-fallback-href
       <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css"
                  asp-fallback-href="~/lib/bootstrap/dist/css/bootstrap.min.css"
                  asp-fallback-test-class="sr-only" 
                  asp-fallback-test-property="position"
                  asp-fallback-test-value="absolute" />
    </environment>
    
    //asp开头的html代码
    //asp-route-MoveID必须和后台MoveID一致
    <a asp-controller="Home" asp-action="Index" asp-route-MoveID="1">跳转</a>
    
    //(include:包括)开发环境
    <environment include="Development">
            <script src="~/lib/jquery/dist/jquery.js"></script>
            <script src="~/lib/bootstrap/dist/js/bootstrap.js"></script>
            <script src="~/js/site.js" asp-append-version="true"></script>
    </environment>
    
    //(exclude:排除)不是开发环境
    <environment exclude="Development">
    //如果window.jQuery为真就用src,否则用asp-fallback-src
            <script src="https://ajax.aspnetcdn.com/ajax/jquery/jquery-3.3.1.min.js"
                    asp-fallback-src="~/lib/jquery/dist/jquery.min.js"
                    asp-fallback-test="window.jQuery"
                    crossorigin="anonymous"
                    integrity="sha384-tsQFqpEReu7ZLhBV2VZlAu7zcOV+rXbYlF2cqB8txI/8aZajjp4Bqd+V6D5IgvKT">
            </script>
            <script src="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"
                    asp-fallback-src="~/lib/bootstrap/dist/js/bootstrap.min.js"
                    asp-fallback-test="window.jQuery && window.jQuery.fn && window.jQuery.fn.modal"
                    crossorigin="anonymous"
                    integrity="sha384-aJ21OjlMXNL5UyIl/XNwTMqvzeRMZH2w8c5cRVpzpU8Y5bApTppSuUkhZXN0VxHd">
            </script>
            <script src="~/js/site.min.js" asp-append-version="true"></script>
    </environment>
  • 相关阅读:
    mysql中profile的使用
    6、MySQL索引种类
    MySql事务
    MySQL视图(view)
    MySql数据库命令基本操作
    2、MySQL常见数据库引擎及比较?
    1、列举常见的关系型数据库和非关系型都有那些?
    Python中的顺序表
    双端队列
    手持移动端特殊链接:打电话,发短信,发邮件
  • 原文地址:https://www.cnblogs.com/-zzc/p/14204059.html
Copyright © 2011-2022 走看看