Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/39.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
Javascript CSS&;在IIS 8(Windows 8)上部署ASP.Net MVC应用程序时未呈现JS文件_Javascript_Css_Asp.net Mvc 4_Razor_Bundling And Minification - Fatal编程技术网

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

Javascript CSS&;在IIS 8(Windows 8)上部署ASP.Net MVC应用程序时未呈现JS文件,javascript,css,asp.net-mvc-4,razor,bundling-and-minification,Javascript,Css,Asp.net Mvc 4,Razor,Bundling And Minification,在远程IIS 8上部署Asp.NET MVC 5 web应用程序时遇到问题!当我启动服务器时,应用程序运行良好,但没有css或js文件工作 我的本地计算机: 我的远程计算机: 单击查看页面源时的我的视图(在浏览器中): 我的登录页面: @model LoginViewModel @{ ViewBag.Title = "Log in"; } <div class="row"> @using (Html.BeginForm("Login", "Account",

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

我的本地计算机:

我的远程计算机:

单击查看页面源时的我的视图(在浏览器中):

我的登录页面:

@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")
 }
@model LoginViewModel
@{
ViewBag.Title=“登录”;
}
@使用(Html.BeginForm(“Login”,“Account”,new{ReturnUrl=ViewBag.ReturnUrl},FormMethod.Post,new{@class=“bootstrap admin Login form”}))
{
@Html.AntiForgeryToken()
@Html.ValidationSummary(true)
登录
@Html.ValidationMessageFor(m=>m.Email,“,new{@class=“text danger”})
@Html.ValidationMessageFor(m=>m.Password,“,new{@class=“text danger”})
@CheckBoxFor(m=>m.RememberMe)
@LabelFor(m=>m.RememberMe)
提交
}
@节脚本{
@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>

,但对我来说什么都不管用

注意:我的一个页面在razor文件中定义了一些样式,它的渲染效果很好!所以我认为问题出在bundle文件中的某个地方

有人能帮我吗

我刚刚在我的Web.Config文件中输入:

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


我的本地机器没有样式(就像远程机器一样),如果它可以帮助人们理解…

如果网站是SSL安全的,请确保您的资源有一个完全限定的地址。这是我想到的第一件事

-我解决了这个问题

谢谢你

我只需在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"));


作者的回答是正确的,但没有帮助。为了解决这个问题,我必须看得更深一点。 我发现,当您将应用程序发布到生产环境中或出于任何原因,并且bundle.config文件未正确配置时,您将遇到CSS/JS未呈现的问题。 为了解决这个问题,我必须在bundle.config文件中做一些更改。 同一文件夹中的所有样式文件都位于一个虚拟路径下,如果其他CSS文件位于不同的文件夹下,则必须为这些文件创建一个新的捆绑包。 e、 我的自定义css名为“site.css”和“bootstrap.css”在同一个文件夹中,所以我创建了

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

                  ));`
然后我也有一些我想包括在项目中。所以我创建了另一个包

bundles.Add(new StyleBundle("~/Content/css/font-awsome").Include(
                 "~/Content/css/font-awesome.css"
            ));
然后,我将这两个路径添加到Layout.cshtml文件中

 @Styles.Render("~/Content/allcss")
@Styles.Render("~/Content/css/font-awsome")

工作起来很有魅力

如果您正在注册捆绑包,是否签入global.asax?在应用程序启动方法中,您应该有以下行:BundleConfig.RegisterBundles(BundleTable.Bundles)@MárcioGonzalez是的,我的global.asax中有它。丢失的资源返回的响应状态代码是什么?@Neps我试图单击,但得到:HTTP错误403.14-禁止Web服务器配置为不列出此目录的内容。@Neps我在IIS中启用了目录浏览,当我再次单击同一链接时,我看到这个包在工作!因为它把我带到了css文件所在的目录!我真的不明白为什么它不在我的页面中呈现!不,我刚检查过,它不是SSL安全的!这是http而不是https!然后从包名称中删除扩展名。这将导致.NET处理该请求并通过BundleModule运行它。试试看,嗯,你能从我的文件中取出一个包并删除它的扩展名吗?我不明白你想说什么!新ScriptBundle(“~/bundles/jquery”)没有扩展名!然后在system.webserver下将其添加到web配置中。我已经把它放在我的web.config文件中了!但它似乎不起作用了!我刚刚在我的问题描述中补充说,您可以看一看,先生,您确定您指的是“bundle.config”而不是BundleConfig.cs吗?如果是这样,我就找不到了。你能告诉我它在哪里吗?我是mvc新手
bundles.Add(new StyleBundle("~/Content/allcss").Include(
                  "~/Content/bootstrap.css",
                  "~/Content/site.css"

                  ));`
bundles.Add(new StyleBundle("~/Content/css/font-awsome").Include(
                 "~/Content/css/font-awesome.css"
            ));
 @Styles.Render("~/Content/allcss")
@Styles.Render("~/Content/css/font-awsome")