Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/326.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 样式不适用于所有ASP.NET MVC4 Internet应用程序视图_C#_Asp.net Mvc 4_Twitter Bootstrap - Fatal编程技术网

C# 样式不适用于所有ASP.NET MVC4 Internet应用程序视图

C# 样式不适用于所有ASP.NET MVC4 Internet应用程序视图,c#,asp.net-mvc-4,twitter-bootstrap,C#,Asp.net Mvc 4,Twitter Bootstrap,我按照以下步骤创建了一个ASP.NET MVC4应用程序:。一切都使用默认样式。然后我更改了_Layout.cshtml页面,删除了我认为不必要的内容,并添加了一些引导。它在主页(显示项目列表的页面(来自数据库)上运行得很好,但是创建、编辑、删除和显示页面(自动生成)以及我现在尝试创建的任何页面都不会用样式更新。他们可以看到布局页面,因为文本在那里,但没有设置样式。有趣的是,如果我添加一个按钮并设置类,那么它看起来就像引导按钮。我不确定要包含什么代码。知道会是什么吗 <!DOCTYPE h

我按照以下步骤创建了一个ASP.NET MVC4应用程序:。一切都使用默认样式。然后我更改了_Layout.cshtml页面,删除了我认为不必要的内容,并添加了一些引导。它在主页(显示项目列表的页面(来自数据库)上运行得很好,但是创建、编辑、删除和显示页面(自动生成)以及我现在尝试创建的任何页面都不会用样式更新。他们可以看到布局页面,因为文本在那里,但没有设置样式。有趣的是,如果我添加一个按钮并设置类,那么它看起来就像引导按钮。我不确定要包含什么代码。知道会是什么吗

<!DOCTYPE html>
    <head>
    <meta name="viewport" content="width=device-width" />

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

    <script type="text/javascript" src="@Url.Content("~/Scripts/jquery-1.9.1.js")"></script>
    <script type="text/javascript" src="@Url.Content("~/Scripts/bootstrap.min.js")"></script>
    <link href="~/Content/bootstrap/bootstrap.css" rel="stylesheet" />

    <link rel="stylesheet" type="text/css" href="css/style.css" media="screen" />
    <link rel="stylesheet" type="text/css" href="css/layout.css" media="screen" />

</head>

<body id="body" style="background-color: transparent !important;">
<form id="form1" method="post" runat="server" enctype="multipart/form-data" class="form-horizontal">
    <div id="wrap">
        <div id="topbar">
            <div id="appTitle">
                <a href="default.aspx">Online Applications</a>
            </div>
            <div class="roundcont">
                <div class="roundtop">
                    <img src="images/tl.gif" alt="" width="8" height="8" class="corner" style="display: none" />
                </div>
            </div>
            <div style="margin-left: 260px; background-color: white;" id="logoScroll">
</body> 

@style.Render(“~/Content/css”)
@Scripts.Render(“~/bundles/modernizer”)
更改:

<link href="~/Content/bootstrap/bootstrap.css" rel="stylesheet" />

致:


ASP.net表单中的波浪号表示根目录。我不认为MVC能以这样的速度解析它,所以我想这是你的问题


摆脱它,看看会发生什么:-)

发布你的_Layout.cshtml。我猜你是在用相对路径引用样式文件。因为MVC控制器看起来像文件夹,所以浏览器最终会找错地方。发布布局代码(加载css的位置),样式不会自动(神奇地)添加。由于Bootstrap是一个不同的框架,您需要将(Bootstrap)类添加到项目上的每个对象中。@KingCronus这听起来可能是个问题。这里怎么了?也许最简单的方法就是将脚本和css文件添加到已经定义的包中。您可以在App_Start/BundleConfig.cs中发现,您既是一位绅士,也是一位学者。我自己永远也不会明白这一点。我用“/”替换了所有的“~/”,它终于可以工作了!没问题,很高兴这对你有帮助。
<link href="/Content/bootstrap/bootstrap.css" rel="stylesheet" />