asp.net web api——BundleConfig类的使用

2021-06-11 21:06

阅读:454

YPE html>

标签:dev   site   color   you   public   java   nts   选择   ons   

BundleConfig设置好,然后在页面就能引用

 

 

public class BundleConfig
{
// 有关捆绑的详细信息,请访问 https://go.microsoft.com/fwlink/?LinkId=301862
public static void RegisterBundles(BundleCollection bundles)
{
bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
"~/Scripts/jquery-{version}.js"));

// 使用要用于开发和学习的 Modernizr 的开发版本。然后,当你做好
// 生产准备就绪,请使用 https://modernizr.com 上的生成工具仅选择所需的测试。


bundles.Add(new ScriptBundle("~/bundles/modernizr").Include(
"~/Scripts/modernizr-*"));

bundles.Add(new ScriptBundle("~/bundles/bootstrap").Include(
"~/Scripts/bootstrap.js"));

bundles.Add(new StyleBundle("~/Content/css").Include(
"~/Content/bootstrap.css",
"~/Content/site.css"));
bundles.Add(new StyleBundle("~/Content/css").Include("~/Content/bootstrap.css", "~/Content/site.css"));
}
}

 

接下来开始引用:

 







@ViewBag.Title
@Styles.Render("~/Content/css")
@Scripts.Render("~/bundles/modernizr")





@RenderBody()



© @DateTime.Now.Year - 我的 ASP.NET 应用程序



@Scripts.Render("~/bundles/jquery")
@Scripts.Render("~/bundles/bootstrap")
@RenderSection("scripts", required: false)

 如果布局页面有定义节点 @RenderSection("ScriptSection", required: false) ,那么在子页面中可以使用 @section ScriptSection{} 来引用js或者css。这个作用相当于在布局页中定义了一个占位,在子页面中去填充这个占位

显示结果

 
 
 
  http-equiv="Content-Type" content="text/html; charset=utf-8"/>
  charset="utf-8" />
  name="viewport" content="width=device-width" />
  Home Page_by_xiaozhao_20190317<span></span>
  href="http://www.soscw.com//Content/bootstrap.css" rel="stylesheet"/>
  href="http://www.soscw.com//Content/site.css" rel="stylesheet"/>
   
 
   
 
  http-equiv="Content-Type" content="text/html; charset=utf-8"/>
 
 
class="navbar navbar-inverse navbar-fixed-top">
 
class="container">
 
class="navbar-header">
 
  class="icon-bar">
  class="icon-bar">
  class="icon-bar">
 
  class="navbar-brand" href="http://www.soscw.com//">应用程序名称
 
 
class="navbar-collapse collapse">
 
    class="nav navbar-nav">
 
  • href="http://www.soscw.com//">主页
  •  
  • href="http://www.soscw.com//Help">API
  •  
     
     
     
     
    class="container body-content">
       
     
    class="jumbotron">
     

    ASP.NET

     

    class="lead">ASP.NET is a free web framework for building great Web sites and Web applications using HTML, CSS, and JavaScript.

     

    href="http://www.soscw.com/https://asp.net" class="btn btn-primary btn-lg">Learn more »

     
     
    class="row">
     
    class="col-md-4">
     

    Getting started

     

    ASP.NET Web API is a framework that makes it easy to build HTTP services that reach

      a broad range of clients, including browsers and mobile devices. ASP.NET Web API
      is an ideal platform for building RESTful applications on the .NET Framework.
     

    class="btn btn-default" href="http://www.soscw.com/https://go.microsoft.com/fwlink/?LinkId=301870">Learn more »

     
     
    class="col-md-4">
     

    Get more libraries

     

    NuGet is a free Visual Studio extension that makes it easy to add, remove, and update libraries and tools in Visual Studio projects.

     

    class="btn btn-default" href="http://www.soscw.com/https://go.microsoft.com/fwlink/?LinkId=301871">Learn more »

     
     
    class="col-md-4">
     

    Web Hosting

     

    You can easily find a web hosting company that offers the right mix of features and price for your applications.

     

    class="btn btn-default" href="http://www.soscw.com/https://go.microsoft.com/fwlink/?LinkId=301872">Learn more »

     
     
       
     
     
     

    © 2019 - 我的 ASP.NET 应用程序

     
     
       
     
       
     
       
       
     
     
       

    asp.net web api——BundleConfig类的使用

    标签:dev   site   color   you   public   java   nts   选择   ons   

    原文地址:https://www.cnblogs.com/zhaoxiansheng/p/10545726.html


    评论


    亲,登录后才可以留言!