简体   繁体   English

ASP.NET MVC 不在登台服务器上呈现脚本文件

[英]ASP.NET MVC Not rendering script files on staging server

I have this problem, where my @Scripts.Render and @Styles.Render Does not exist in the current context.我有这个问题,我的 @Scripts.Render 和 @Styles.Render 在当前上下文中不存在。 I've tried to trouleshoot, but failed at catching the problem.我试图排除故障,但未能解决问题。 Can someone help me with the code?有人可以帮我写代码吗?

<head>
        <meta charset="utf-8" />
        <title>@ViewBag.Title - My ASP.NET MVC Application</title>
        <link href="~/favicon.ico" rel="shortcut icon" type="image/x-icon" />
        <meta name="viewport" content="width=device-width" />
        @Styles.Render("~/Content/css")
        @Scripts.Render("~/bundles/modernizr")
        <script src="~/Scripts/angular.min.js"></script>
    
        <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.4/angular-route.js"></script>
        @*    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.0rc1/angular-route.min.js"></script>*@
        <script src="~/Application/App.js"></script>
        <script src="~/Application/Routing.js"></script>
    
    </head>

     @Scripts.Render("~/bundles/jquery")

Please try the following请尝试以下

Install the "Optimization" pack and then add namespaces in the config file.安装“优化”包,然后在配置文件中添加命名空间。 Add a namespace reference in the config files like:在配置文件中添加命名空间引用,例如:

<add namespace="System.Web.Optimization" />

Your config ~/Views/Web.Config needs to be added the System.Web.Optimization namespace:您的配置 ~/Views/Web.Config 需要添加 System.Web.Optimization 命名空间:

<system.web>
    <pages>
      <namespaces>
        <add namespace="System.Web.Optimization"/>
      </namespaces>
    </pages>
</system.web>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM