在 IIS 8 (Windows 8) 上部署 ASP.Net MVC 应用程序时未呈现 CSS 和 JS 文件

2024-01-05

我在远程 IIS 8 上部署 Asp.NET MVC 5 Web 应用程序时遇到问题!当我启动服务器时,应用程序运行良好,但没有 css 或 js 文件运行!

my local machine : enter image description here

我的远程机器:

当我点击查看页面源代码(在浏览器中)时我的视图:

<!DOCTYPE html>
<html>
 <head>
  <meta charset="utf-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Log in - My MVC Admin Template</title>
    <link href="/Test/Deploy/Content/Theme?v=A1Wwh5B5yTT6Q-34hA0bU7wzaNpIMgCZT8xJ-IAWWVY1" rel="stylesheet"/>

    <script src="/Test/Deploy/bundles/modernizr?v=wBEWDufH_8Md-Pbioxomt90vm6tJN2Pyy9u9zHtWsPo1"></script>


 </head>
<body class="bootstrap-admin-with-small-navbar">
<div class="container">
    <div class="row">
     <div class="row">
       <form action="/Test/Deploy/" class="bootstrap-admin-login-form" method="post"><input name="__RequestVerificationToken" type="hidden" value="C7q6oci5GoiOMjIeCGgn9-U4lMlx54WJz8117lyBbFcbDak6TzJE2z3kKeBkvyJTJxg6viMGh8dOxCUV2qUP87bZBWyXgMsx3g9Tozmxoc41" />        
        <h1>Login</h1>
         <div class="form-group">
            <input class="form-control" type="text" name="Email" placeholder="Email">
             <span class="field-validation-valid text-danger" data-valmsg-for="Email" data-valmsg-replace="true"></span>
             </div>
             <div class="form-group">
        <input class="form-control" type="password" name="Password" placeholder="Password">
        <span class="field-validation-valid text-danger" data-valmsg-for="Password" data-valmsg-replace="true"></span>
    </div>
    <div class="form-group">
        <div>
            <div class="checkbox">
                <input data-val="true" data-val-required="The Remember me? field is required." id="RememberMe" name="RememberMe" type="checkbox" value="true" /><input name="RememberMe" type="hidden" value="false" />
                <label for="RememberMe">Remember me?</label>
            </div>
        </div>
    </div>
    <button class="btn btn-lg btn-primary" type="submit">Submit</button>
  </form>
   </div>
    </div>
    <div class="row">
        <hr>
        <footer role="contentinfo">
            <p>&copy;  2015 -  <a href="" target="_blank">Test</a></p>
        </footer>
    </div>
</div>

<script src="/Test/Deploy/bundles/jquery?v="></script>

<script src="/Test/Deploy/bundles/bootstrap?v=a0JlrK3HWJYO4CANWtnjZQ6r-FHTgFewh3ItuNGmfr41"></script>


<script src="/Test/Deploy/bundles/jqueryval?v=NOVQDySGO89wzMzO5x7mWS4C_uAdynpZe_Lk2y-xEM41"></script>



<script>
    (function (i, s, o, g, r, a, m) {
        i['GoogleAnalyticsObject'] = r; i[r] = i[r] || function () {
            (i[r].q = i[r].q || []).push(arguments)
        }, i[r].l = 1 * new Date(); a = s.createElement(o),
            m = s.getElementsByTagName(o)[0]; a.async = 1; a.src = g; m.parentNode.insertBefore(a, m)
    })(window, document, 'script', '//www.google-analytics.com/analytics.js', 'ga');

    ga('create', 'UA-45396411-1', 'azurewebsites.net');
    ga('send', 'pageview');

</script>

我的 BundleConfig.cs :

    public class BundleConfig
{
    public static void AddDefaultIgnorePatterns(IgnoreList ignoreList)
    {
        if (ignoreList == null)
            throw new ArgumentNullException("ignoreList");
        ignoreList.Ignore("*.intellisense.js");
        ignoreList.Ignore("*-vsdoc.js");
        ignoreList.Ignore("*.debug.js", OptimizationMode.WhenEnabled);
        //ignoreList.Ignore("*.min.js", OptimizationMode.WhenDisabled);
        ignoreList.Ignore("*.min.css", OptimizationMode.WhenDisabled);
    }

    // For more information on bundling, visit http://go.microsoft.com/fwlink/?LinkId=301862
    public static void RegisterBundles(BundleCollection bundles)
    {
        bundles.IgnoreList.Clear();
        AddDefaultIgnorePatterns(bundles.IgnoreList);
        bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
            "~/Scripts/jquery-{version}.js"));

        bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include(
            "~/Scripts/jquery.validate*"));

        // Use the development version of Modernizr to develop with and learn from. Then, when you're
        // ready for production, use the build tool at http://modernizr.com to pick only the tests you need.
        bundles.Add(new ScriptBundle("~/bundles/modernizr").Include(
            "~/Scripts/modernizr-*"));

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

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

        bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
            "~/Scripts/jquery-{version}.js"));

        bundles.Add(new ScriptBundle("~/bundles/jqueryui").Include(
            "~/Scripts/jquery-ui-{version}.js"));

        bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include(
            "~/Scripts/jquery.unobtrusive*",
            "~/Scripts/jquery.validate*"));

        // Use the development version of Modernizr to develop with and learn from. Then, when you're
        // ready for production, use the build tool at http://modernizr.com to pick only the tests you need.
        bundles.Add(new ScriptBundle("~/bundles/modernizr").Include(
            "~/Scripts/modernizr-*"));

        bundles.Add(new ScriptBundle("~/bundles/bootstrap").Include(
            "~/Scripts/bootstrap.js"
            , "~/Scripts/twitter-bootstrap-hover-dropdown.js"
            ));

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

        bundles.Add(new StyleBundle("~/Content/Theme/base/css").Include(
            "~/Content/Theme/base/jquery.ui.core.css",
            "~/Content/Theme/base/jquery.ui.resizable.css",
            "~/Content/Theme/base/jquery.ui.selectable.css",
            "~/Content/Theme/base/jquery.ui.accordion.css",
            "~/Content/Theme/base/jquery.ui.autocomplete.css",
            "~/Content/Theme/base/jquery.ui.button.css",
            "~/Content/Theme/base/jquery.ui.dialog.css",
            "~/Content/Theme/base/jquery.ui.slider.css",
            "~/Content/Theme/base/jquery.ui.tabs.css",
            "~/Content/Theme/base/jquery.ui.datepicker.css",
            "~/Content/Theme/base/jquery.ui.progressbar.css",
            "~/Content/Theme/base/jquery.ui.theme.css"));

        //Calendar css file
        bundles.Add(new StyleBundle("~/Content/fullcalendarcss").Include(
            "~/Content/themes/jquery.ui.all.css",
            "~/Content/fullcalendar.css"));

        //Calendar Script file
        bundles.Add(new ScriptBundle("~/bundles/fullcalendarjs").Include(
            "~/Scripts/jquery-ui-1.10.4.min.js",
            "~/Scripts/fullcalendar.min.js"));

        bundles.Add(new ScriptBundle("~/bundles/vendors").Include(
            "~/Content/Theme/vendors/uniform/jquery.uniform.js"
            , "~/Content/Theme/vendors/chosen.jquery.js"
            , "~/Content/Theme/vendors/bootstrap-datepicker/js/bootstrap-datepicker.js"
            ,
            "~/Content/Theme/vendors/bootstrap-wysihtml5-rails-b3/vendor/assets/javascripts/bootstrap-wysihtml5/wysihtml5.js"
            ,
            "~/Content/Theme/vendors/bootstrap-wysihtml5-rails-b3/vendor/assets/javascripts/bootstrap-wysihtml5/core-b3.js"
            , "~/Content/Theme/vendors/twitter-bootstrap-wizard/jquery.bootstrap.wizard-for.bootstrap3.js"
            , "~/Content/Theme/vendors/boostrap3-typeahead/bootstrap3-typeahead.js"
            , "~/Content/Theme/vendors/easypiechart/jquery.easy-pie-chart.js"
            , "~/Content/Theme/vendors/ckeditor/ckeditor.js"
            , "~/Content/Theme/vendors/tinymce/js/tinymce/tinymce.js"
            ,
            "~/Content/Theme/vendors/bootstrap-wysihtml5-rails-b3/vendor/assets/javascripts/bootstrap-wysihtml5/wysihtml5.js"
            ,
            "~/Content/Theme/vendors/bootstrap-wysihtml5-rails-b3/vendor/assets/javascripts/bootstrap-wysihtml5/core-b3.js"
            , "~/Content/Theme/vendors/jGrowl/jquery.jgrowl.js"
            , "~/Content/Theme/vendors/bootstrap-datepicker/js/bootstrap-datepicker.js"
            , "~/Content/Theme/vendors/sparkline/jquery.sparkline.js"
            , "~/Content/Theme/vendors/tablesorter/js/jquery.tablesorter.js"
            , "~/Content/Theme/vendors/flot/jquery.flot.js"
            , "~/Content/Theme/vendors/flot/jquery.flot.selection.js"
            , "~/Content/Theme/vendors/flot/jquery.flot.resize.js"
            , "~/Content/Theme/vendors/fullcalendar/fullcalendar.js"
            ));

        bundles.Add(new StyleBundle("~/Content/Theme").Include(
            "~/Content/bootstrap.css",
            "~/Content/bootstrap-theme.css",
            "~/Content/Theme/css/bootstrap-admin-theme.css",
            "~/Content/Theme/css/site.css"));

        bundles.Add(new StyleBundle("~/Content/Vendors").Include(
            "~/Content/Theme/vendors/bootstrap-datepicker/css/datepicker.css"
            , "~/Content/Theme/css/datepicker.fixes.css"
            , "~/Content/Theme/vendors/uniform/themes/default/css/uniform.default.min.css"
            , "~/Content/Theme/css/uniform.default.fixes.css"
            , "~/Content/Theme/vendors/chosen.min.css"
            ,
            "~/Content/Theme/vendors/bootstrap-wysihtml5-rails-b3/vendor/assets/stylesheets/bootstrap-wysihtml5/core-b3.css"
            , "~/Content/Theme/vendors/easypiechart/jquery.easy-pie-chart.css"
            , "~/Content/Theme/vendors/easypiechart/jquery.easy-pie-chart_custom.css"
            ,
            "~/Content/Theme/vendors/bootstrap-wysihtml5-rails-b3/vendor/assets/stylesheets/bootstrap-wysihtml5/core-b3.css"
            , "~/Content/Theme/vendors/jGrowl/jquery.jgrowl.css"
            , "~/Content/Theme/vendors/bootstrap-datepicker/css/datepicker.css"
            , "~/Content/Theme/vendors/fullcalendar/fullcalendar.css"));
    }
}

我的登录页面:

@model LoginViewModel
@{
  ViewBag.Title = "Log in";
 }

 <div class="row">
     @using (Html.BeginForm("Login", "Account", new { ReturnUrl = ViewBag.ReturnUrl }, FormMethod.Post, new { @class = "bootstrap-admin-login-form" }))
{
    @Html.AntiForgeryToken()
    @Html.ValidationSummary(true)

    <h1>Login</h1>
    <div class="form-group">
        <input class="form-control" type="text" name="Email" placeholder="Email">
        @Html.ValidationMessageFor(m => m.Email, "", new { @class = "text-danger" })
    </div>
    <div class="form-group">
        <input class="form-control" type="password" name="Password" placeholder="Password">
        @Html.ValidationMessageFor(m => m.Password, "", new { @class = "text-danger" })
    </div>
    <div class="form-group">
        <div>
            <div class="checkbox">
                @Html.CheckBoxFor(m => m.RememberMe)
                @Html.LabelFor(m => m.RememberMe)
            </div>
        </div>
    </div>
    <button class="btn btn-lg btn-primary" type="submit">Submit</button>
}
</div>
@section Scripts {
    @Scripts.Render("~/bundles/jqueryval")
 }

在我的 Web.Config 文件中,我输入了以下内容:

 <system.webServer>
   <modules runAllManagedModulesForAllRequests="true">
     <remove name="BundleModule" />
     <add name="BundleModule" type="System.Web.Optimization.BundleModule" />
     <remove name="FormsAuthentication" />
     <remove name="ApplicationInsightsWebTracking" />
     <add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Extensibility.Web.RequestTracking.WebRequestTrackingModule, Microsoft.ApplicationInsights.Extensibility.Web" preCondition="managedHandler" />
   </modules>
   <validation validateIntegratedModeConfiguration="false" />
 </system.webServer>

我在网上看到了很多解决方案,包括服务器端和项目端!我启用了静态内容在windows功能中。我改变了BundleConfig.cs按此处所述归档捆绑程序不包含 .min 文件 https://stackoverflow.com/questions/11980458/bundler-not-including-min-files,但对我来说没有任何作用!

NB: 我的一个页面在 razor 文件中定义了一些样式,它渲染得很好!所以我认为问题出在捆绑文件中的某个地方!

有人可以帮我吗?

我刚刚放入我的 Web.Config 文件:

  <compilation debug="false" targetFramework="4.5" />

如果它可以帮助别人理解的话,我本地机器上的结果是没有样式的(就像远程的一样)...


我解决了问题!

谢谢使用 Asp.net 4.0 C# 不应用 css 和 js 进行捆绑和缩小 https://stackoverflow.com/questions/21299540/bundling-minification-not-applying-css-js-using-asp-net-4-0-c-sharp !

我所要做的就是在我的bundleConfig.cs 文件中更改名称:

  bundles.Add(new StyleBundle("~/Content/Theme").Include(
            "~/Content/bootstrap.css",
            "~/Content/bootstrap-theme.css",
            "~/Content/Theme/css/bootstrap-admin-theme.css",
            "~/Content/Theme/css/site.css"));

to

  bundles.Add(new StyleBundle("~/Content/allcss").Include(
            "~/Content/bootstrap.css",
            "~/Content/bootstrap-theme.css",
            "~/Content/Theme/style/bootstrap-admin-theme.css",
            "~/Content/Theme/style/site.css"));
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

在 IIS 8 (Windows 8) 上部署 ASP.Net MVC 应用程序时未呈现 CSS 和 JS 文件 的相关文章

  • LitElement 不更新列表中的复选框

    我有一个简单的清单 每个项目都有一个删除按钮 当我选中第一个项目然后删除它时 列表会更新 删除该项目 但会选中下一个项目的复选框 下一项的属性是正确的 这是我的代码 import LitElement html from lit eleme
  • 我应该如何使用 Bootstrap 设计 Django 验证错误的样式?

    当 Django 中的表单出现验证错误时 错误会在包含类的列表中给出errorlist 可以通过设置使用 Bootstrap 为元素指定错误样式class alert alert error 结合这些并使用 Bootstrap 的错误样式来
  • 使文本在 div 内可滚动

    我希望将一些冗长的文本包含到div可以通过向上或向下滚动来查看文本 现在 描述 文本呈现如下并且位于一个 div class div
  • 如何限制注册用户尝试投票两次[关闭]

    Closed 这个问题需要多问focused help closed questions 目前不接受答案 我对 php 编码和网站设计非常陌生 我正在尝试开发一个在线投票系统 只允许注册用户投票 已完成所有操作并且工作正常 但我需要的帮助是
  • 在javascript/jQuery中设置Java的数据结构

    有没有办法在javascript中像java一样创建集合数据结构 唯一集合 对于一组字符串 我只使用值为 true 的对象 var obj obj foo true obj bar true if obj foo foo in set 这基
  • 如何跨页面播放背景音乐

    我已经读过这个问题 我知道它只能用框架来完成 我真的不想要全站点 AJAX 如何在多个 HTML 页面上播放背景音频 https stackoverflow com questions 4210370 how to play a backg
  • 仅在文件下载完成后设置 cookie。

    我有一个场景 我想告诉用户下载完成并提示关闭按钮 为此 我使用 jquery 插件来连续监视 cookie 以了解下载何时完成 我的问题是我想设置这个cookie fileDownload true and path 下载完成后立即进行 为
  • Google Maps API v3 在地图加载后不会禁用滚轮

    我正在网站上实现谷歌地图 一切都工作得很好 除了地图加载后我似乎无法禁用滚轮 如果我在地图加载之前将选项设置为scrollwheel false 则滚轮将被禁用 但如果我稍后尝试执行此操作 我有一个启用 禁用滚轮的复选框 以下是我在页面加载
  • 与 webpack 捆绑后,无法读取枚举的未定义属性

    我有一个 React 库 我想使用 Webpack 来构建它 该库是使用 Typescript 编写的 似乎一切正常 但由于某种原因枚举却不起作用 当我将库安装到我的 React 应用程序中时 我发现Cannot read properti
  • 我想在数据表中使用 Div 结构而不是 Table。是否可以?

    我想用数据表 https datatables net 用div结构代替表格 目的是满足设计要求 有什么可能的方法或替代方案吗 不 您将无法执行此操作 Datatables 的核心仅适用于表格元素和子 thead tbody tfooter
  • 从 ASP.NET Web API 返回 HTML

    如何从 ASP NET MVC Web API 控制器返回 HTML 我尝试了下面的代码 但由于未定义 Response Write 而出现编译错误 public class MyController ApiController HttpP
  • CSS:DIV 中的文本被截断

    我正在致力于集成一个 jQuery 插件 该插件会隐藏页面的某些部分 直到用户单击 喜欢按钮 Facebook 小部件的部分文本被切断 我已经尝试过 CSS 但无法让它完全显示 如果容器的宽度设置正确 还有什么可能导致文本被截断 例子 ht
  • 如何使我的网站兼容移动设备和平板电脑? [关闭]

    Closed 这个问题需要多问focused help closed questions 目前不接受答案 我想让我现有的网站在手机 平板电脑上查看时自动调整 甚至在您在桌面上调整屏幕时自动调整 如果失败的话 如果太难 你有什么建议 我基本上
  • 内联块元素和块元素之间的空间

    这两个 div 之间的空间是多少 我什至删除了 html 中的空白 div div div div http jsfiddle net 9thpuvwa http jsfiddle net 9thpuvwa 现在 如果第一个 div asd
  • Wordpress 上的 Javascript 注入预防

    我的 WordPress 博客得到以下内容恶意的注入脚本 eval function p a c k e d e function c return c
  • 如何在 JS 文件中使用 Github 机密

    我有一个基本的 git 存储库 其中包含用于构建和部署的 github 操作 主要是 HTML 和 TS 文件 但是我必须在一些需要保密的 API 密钥中使用 所以我想办法为他们使用 GITHUB SECRETS 如何在我的 js 或 TS
  • 如何使用 CSS3 更改图像的颜色?

    这有效 a color hsla 0 100 50 0 2 这并不 img color hsla 0 100 50 0 2 有没有类似的东西img opacity 1 允许定义图像的 hsl 值 文本和图像是两个不同的东西 文本由浏览器根据
  • 如何使用 javascript 获取 html5 视频的缩略图?

    我找到了根据 URL 获取视频缩略图的 JavaScript 代码 不过 我只在 YouTube 和 Vimeo 上找到了这个 似乎没有人列出如何处理旨在嵌入 html5 视频标签的视频的示例 能做到吗 谢谢 是的 您可以使用视频作为画布的
  • 如何使用 JavaScript 大致计算网站的连接速度?

    如何使用 JavaScript 大致计算网站的连接速度 我想创建一个像这样的javascript小部件 它将计算打开当前打开页面的速度 我想问是否可以仅使用 javascript 来完成此操作以及想法是什么 Update 请注意 页面大小始
  • MutationOberserver 回调是否在修改观察到的元素的同一动画帧内触发? [关闭]

    Closed 这个问题是无法重现或由拼写错误引起 help closed questions 目前不接受答案 假设我对使用以下命令创建的框架内的元素进行了更改window requestAnimationFrame并且被修改的元素正在被观察

随机推荐