Visual Studio 在调试时提取了错误的 CSS 文件

Visual Studio is Pulling Wrong CSS File on Debug

我最近不得不从我的团队资源管理器下载我网站的新版本。现在似乎在使用正确的 css 文件时遇到了问题。就好像它正在某处查看旧版本,但我不知道为什么或在哪里查看。

我检查了捆绑包,它有正确的文件 name/location。我检查了文件,它的代码正确。

这是我的代码

布局(直到头部减去分析)

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8" />
    <title>@ViewBag.Title - Coverpools Dealer Portal</title>
    <link href="~/favicon.ico" rel="shortcut icon" type="image/x-icon" />
    <meta name="viewport" content="width=device-width" />

    @Styles.Render("~/Content/magnific_css")
    @Scripts.Render("~/bundles/modernizr")
    <link href="~/Content/magnific-popup.css" rel="stylesheet" />
    @Styles.Render("~/Content/themes/base/css")
    @Styles.Render("~/Content/css")

</head>

捆绑包(包括所有捆绑包,以防遗漏)

using System.Web;
using System.Web.Optimization;

namespace Infotech.Coverpools.Portal.Tintaglia.Web
{
    public class BundleConfig
    {
        // For more information on Bundling, visit http://go.microsoft.com/fwlink/?LinkId=254725
        public static void RegisterBundles(BundleCollection bundles)
        {
            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/quotes").Include(
                        "~/Scripts/jquery-{version}.js",
                        "~/Scripts/jquery-ui-{version}.js",
                        "~/Scripts/jquery.unobtrusive*",
                        "~/Scripts/jquery.validate*",
                        "~/Scripts/quotes.js"));

            bundles.Add(new ScriptBundle("~/bundles/magnific").Include(
                        "~/Scripts/jquery.magnific-popup.min.js"));

            bundles.Add(new StyleBundle("~/Content/css").Include(
                "~/Content/site.css",  
                "~/Content/PagedList.css", 
                "~/Content/Responsive.css", 
                "~/Content/custom.css")); // this is the custom file I believe it should be pulling

            bundles.Add(new StyleBundle("~/Content/magnific_css").Include("~/Content/magnific-popup.css"));

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

        }
    }
}

custom.css 来自我的本地站点(它应该位于..Web/Content/custom.css)

/* main layout
----------------------------------------------------------*/


/* site title
----------------------------------------------------------*/


/* login
----------------------------------------------------------*/


/* NOTICE THIS SECTION IS MISSING THE RUNNING VERSION menu
----------------------------------------------------------*/
ul#accountMenu {
    font-size: 1em;
    font-weight: 600;
    margin: 0 0 5px;
    padding: 0;
    text-align: left;
}
ul#accountMenu li {
    display: inline;
    list-style: outside none none;
    padding-left: 15px;
}
ul#accountMenu li a {
    background: rgba(0, 0, 0, 0) none repeat scroll 0 0;
    color: #999;
    text-decoration: none;
}
ul#accountMenu li a:hover {
    color: #333;
    text-decoration: none;
}


/* page elements
----------------------------------------------------------*/
/*Text*/

.important-message{
    color: red
}


/* featured */


/* page titles */


/* features */


/* ordered list */



/* content */

/* login page */

/* contact */


/* forms */


/* info and errors */


/* styles for validation helpers */


/* tables
----------------------------------------------------------*/


/********************
*   Mobile Styles   *
********************/
/*@media only screen and (max-width: 850x) { */

    /* header
    ----------------------------------------------------------*/


    /* logo */


    /* login */



    /* menu */


    /* main layout
    ----------------------------------------------------------*/


    /* page content */


    /* ordered list */


    /* features */


    /* forms */

    /* login page */



    /* mobile footer
    ----------------------------------------------------------*/

custom.css(来自运行版本)

/* main layout
----------------------------------------------------------*/


/* site title
----------------------------------------------------------*/


/* login
----------------------------------------------------------*/


/* menu
----------------------------------------------------------*/



/* page elements
----------------------------------------------------------*/
/* featured */


/* page titles */


/* features */


/* ordered list */



/* content */

/* login page */

/* contact */


/* forms */


/* info and errors */


/* styles for validation helpers */


/* tables
----------------------------------------------------------*/


/********************
*   Mobile Styles   *
********************/
@media only screen and (max-width: 850x) {

    /* header
    ----------------------------------------------------------*/


    /* logo */


    /* login */



    /* menu */


    /* main layout
    ----------------------------------------------------------*/


    /* page content */


    /* ordered list */


    /* features */


    /* forms */

    /* login page */



    /* mobile footer
    ----------------------------------------------------------*/

生成 HTML 直到头

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8" />
    <title>All Users - Coverpools Dealer Portal</title>
    <link href="/favicon.ico" rel="shortcut icon" type="image/x-icon" />
    <meta name="viewport" content="width=device-width" />

    <link href="/Content/magnific-popup.css" rel="stylesheet"/>

    <script src="/Scripts/modernizr-2.6.2.js"></script>

    <link href="/Content/magnific-popup.css" rel="stylesheet" />
    <link href="/Content/themes/base/jquery.ui.core.css" rel="stylesheet"/>
<link href="/Content/themes/base/jquery.ui.resizable.css" rel="stylesheet"/>
<link href="/Content/themes/base/jquery.ui.selectable.css" rel="stylesheet"/>
<link href="/Content/themes/base/jquery.ui.accordion.css" rel="stylesheet"/>
<link href="/Content/themes/base/jquery.ui.autocomplete.css" rel="stylesheet"/>
<link href="/Content/themes/base/jquery.ui.button.css" rel="stylesheet"/>
<link href="/Content/themes/base/jquery.ui.dialog.css" rel="stylesheet"/>
<link href="/Content/themes/base/jquery.ui.slider.css" rel="stylesheet"/>
<link href="/Content/themes/base/jquery.ui.tabs.css" rel="stylesheet"/>
<link href="/Content/themes/base/jquery.ui.datepicker.css" rel="stylesheet"/>
<link href="/Content/themes/base/jquery.ui.progressbar.css" rel="stylesheet"/>
<link href="/Content/themes/base/jquery.ui.theme.css" rel="stylesheet"/>

    <link href="/Content/site.css" rel="stylesheet"/>
<link href="/Content/PagedList.css" rel="stylesheet"/>
<link href="/Content/Responsive.css" rel="stylesheet"/>
<link href="/Content/custom.css" rel="stylesheet"/>

</head>

我什至尝试硬编码 custom.css 但仍然得到相同的 custom.css 文件。好像它正在其他地方寻找文件。

似乎存在浏览器的缓存问题不同的浏览器有不同的缓存策略虽然你的 css 被缓存在浏览器中所以它总是变旧了我想让你做的只是把 ?foo=1234 在 css / js 导入结束时,将 1234 更改为您喜欢的任何值。看一下 SO html 来源的例子。

有这样的想法吗?参数在请求中无论如何都会被丢弃/忽略,您可以在推出新版本时更改该数字。

尝试按 ctrl+R 进行 HARD REFRESH | ctrl+shift+R | cntrl+F5 或者你可以找到如何在这个 link 上针对不同的浏览器进行硬刷新