【问题标题】:Webpage styles disappeared when I deployed my mvc app using IIS当我使用 IIS 部署我的 mvc 应用程序时,网页样式消失了
【发布时间】:2017-08-17 07:42:13
【问题描述】:

每当我调试我的网络应用程序时,它都会显示如下:

但是当我使用 IIS 发布它时,样式消失了

这是我的 BundleConfig.cs

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*"));

        bundles.Add(new ScriptBundle("~/bundles/knockout").Include(
                    "~/Scripts/knockout-2.1.0.js",
                    "~/Scripts/knockout-2.1.0.debug.js"));

        // 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 StyleBundle("~/Content/css").Include("~/Content/site.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"));
    }
}

这是我的页面:

@model newInOut.Models.Employees_Master

@{
    ViewBag.Title = "Login";
    Layout = null;
}
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<link href="~/Content/LoginStyle.css" rel="stylesheet" />




<div class="flex-container">
@using (Html.BeginForm("Login", "HR", FormMethod.Post, new { @class = "login" }))
{
    <div class="logo text-uppercase"><span>Kita</span><strong class="logo text-primary">MerX</strong></div>
    @Html.AntiForgeryToken()
    @Html.ValidationSummary(true)


<table>

    <tr>
        <td>@Html.TextBoxFor(a => a.EmployeeID, new { @class = "fa fa-user", placeholder = "ID", style = "font-size:24px" }) </td>
        <td class="fa fa-user"style="font-size:24px"></td>
        <td>@Html.ValidationMessageFor(a => a.EmployeeID)</td>
    </tr>
    <tr>
        <td>@Html.TextBoxFor(a => a.Employee_Password, new { @class = "fa fa-key", placeholder = "Password", @type = "Password" }) </td>
         <td class="fa fa-key" style="font-size:24px"></td>
         <td>@Html.ValidationMessageFor(a => a.Employee_Password)</td>
    </tr> 

    <tr>
       <td> <button type="submit" value="Login" class="state">LOGIN</button></td>
    </tr>

</table>   

}</div>

我尝试关注this,但没有解决。 我使用了Publish,然后在Profile 选项卡中,我创建了一个新的Publish Profile, 然后我使用发布方法为File System,将我的目标位置放在wwwroot 文件夹中,然后在Settings 选项卡中,我使用Release。 然后在IIS管理器中,将新建的文件夹转换成App,然后浏览。

【问题讨论】:

  • 签入网络的 chrome 控制台选项卡。 css文件有错误吗?
  • @Amit,它是空白的。所以,没有
  • @Amit,当我刷新它时,它显示“资源解释为样式表,但使用 MIME 类型文本/纯文本传输:“localhost/InOuter/Content/LoginStyle.css"。”
  • type="text/css" 需要添加到标签中

标签: css iis deployment publish


【解决方案1】:

另外,您的页面上似乎没有包含 stylebundle "~/Content/css"。使用 @Styles.render("~/Content/css") 包含在 bundle.config 中定义的 css 包。

【讨论】:

  • 请问我将把“@Styles.render("~/Content/css")”放在哪里?是否在 BundleConfig.cs 中?
  • 在您创建 html 的查看页面上
猜你喜欢
  • 2021-04-16
  • 1970-01-01
  • 1970-01-01
  • 2021-12-11
  • 1970-01-01
  • 1970-01-01
  • 2021-11-04
  • 1970-01-01
  • 2020-07-10
相关资源
最近更新 更多