bootstrap在本地工作,但在部署时不工作

时间:2014-04-02 03:09:53

标签: javascript jquery css asp.net-mvc twitter-bootstrap

我使用MVC框架和bootstrap来优化网站。一切都在本地工作,但不在服务器上。该网站没有css watsoever。首页也应该是旋转木马滑块,现在它只是以垂直方式显示的所有图片。有什么问题?

这是我的代码:

@using System.Web.Optimization;
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>@ViewBag.Title - The Secured Password</title>
@Scripts.Render("~/bundles/bootstrap")
@Styles.Render("~/Content/css")
@Scripts.Render("~/bundles/modernizr")
@Scripts.Render("~/bundles/jquery")
@*@Scripts.Render("~/bundles/jqueryval")*@
@RenderSection("scripts", required: false)
</head>
<body>
<div class="navbar-wrapper">
    <div class="container">

谢谢!

编辑:

这是渲染的标题:

<link href="/Content/css?v=UV-jZ4aDFGX-mj3fDEnMFNwudw9kdbZQj1zFCxtmgps1"   rel="stylesheet">

<script src="/bundles/modernizr?v=wBEWDufH_8Md-Pbioxomt90vm6tJN2Pyy9u9zHtWsPo1">   </script><style type="text/css"></style>

<script src="/bundles/jquery?v=FVs3ACwOLIVInrAl5sdzR2jrCDmVOWFbZMY6g6Q0ulE1"></script>

<script src="/bundles/bootstrap?v=HHeOtfpYTGpvkQWzPsmQOp39ZdG4zLSAsANOtnmyV-g1"></script>

编辑#2: 以下是bundleconfig.cs的内容:

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

        bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include(
                    "~/Content/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(
                    "~/Content/Scripts/modernizr-*"));

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

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

3 个答案:

答案 0 :(得分:0)

没有任何东西可以渲染Bootstrap自己的css文件(bootstrap [.min] .css和bootstrap-theme [.min] .css)。

答案 1 :(得分:0)

现在已经修好了。我只是更改了cshtml代码:

@Scripts.Render("~/bundles/bootstrap")
@Styles.Render("~/Content/css")
@Scripts.Render("~/bundles/modernizr")
@Scripts.Render("~/bundles/jquery")

部分是正常的HTML代码

<script src="/bundles/bootstrap.css"></script>

解决方案不多,但它解决了我的问题。

谢谢大家的帮助。

答案 2 :(得分:0)

bootstrap.css是否包含在你的&#34;〜/ Content / css&#34;束?检查你的BundleConfig.cs RegisterStyleBundles函数,看看你是否正确地包含了该bundle中的bootstrap css,因为你没有渲染任何其他样式包,如果它没有正确包含在那个包中那么这肯定会解释为什么你没有获得CSS。