部署版本的MVC站点不起作用

时间:2015-06-09 20:14:18

标签: c# asp.net-mvc deployment

我有一个MVC Web应用程序(.csproj),它可以在Visual Studio中以及解决方案中的其他项目中正常工作。但是,当我部署它时,要么使用Subversion& TeamCity,甚至使用Visual Studio的发布向导(到本地文件夹),它构建成功,但它无法正常运行。

例如,我注意到一些CSS文件没有加载到页面。在查看Chrome开发者工具以及Fiddler之后,事实证明甚至没有请求特定文件的请求。在可用的站点版本中(即在Visual Studio中),从/App_Start/BundleConfig.cs请求css文件。事实证明,甚至没有部署整个文件夹。手动复制该文件夹也没有解决问题。

发生了什么?

谢谢,

更新

这是我的BundleConfig.cs:

using System.Web.Optimization;

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

            bundles.Add(new ScriptBundle("~/Scripts/google").Include(
                        "~/Scripts/jsapi.js"));

            bundles.Add(new ScriptBundle("~/Scripts/easyquery").Include(
                        "~/Scripts/jquery-ui.js",
                        "~/Scripts/EasyQuery/eq.all.min.js",
                        "~/Scripts/EasyQuery/eq.view.basic.js"));

            bundles.Add(new ScriptBundle("~/Scripts/validate").Include(
                        "~/Scripts/jquery.validate.unobtrusive.min.js",
                        "~/Scripts/jquery.validate.min.js"));

            bundles.Add(new ScriptBundle("~/Scripts/kendo").Include(
                //"~/Scripts/Kendo/jquery.min.js",
                        "~/Scripts/Kendo/kendo.all.min.js",
                        "~/Scripts/Kendo/kendo.aspnetmvc.min.js"));

            bundles.Add(new ScriptBundle("~/Scripts/bootstrap").Include(
                      "~/Scripts/bootstrap.min.js",
                      "~/Scripts/respond.min.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-2.8.3.js"));

            /******************************************* STYLES *******************************************/
            bundles.Add(new StyleBundle("~/Content/css").Include(
                        "~/Content/Site.css"));

            bundles.Add(new StyleBundle("~/Content/jquery").Include(
                        "~/Content/jquery-ui.css"));

            bundles.Add(new StyleBundle("~/Content/easyquery").Include(
                        "~/Content/EasyQuery/easyquery.css",
                        "~/Content/EasyQuery/eqview.css",
                        "~/Content/bootstrap.min.css"));

            bundles.Add(new StyleBundle("~/Content/bootstrap").Include(
                        "~/Content/bootstrap.min.css"));

            bundles.Add(new StyleBundle("~/Content/kendo").Include(
                      "~/Content/Kendo/kendo.bootstrap.min.css",
                      "~/Content/Kendo/kendo.common-bootstrap.min.css"));

            bundles.Add(new StyleBundle("~/Content/errorcss").Include(
                      "~/Content/ErrorCss.css"));

            bundles.Add(new StyleBundle("~/Content/fonts").Include(
                      "~/Content/FontCss.css"
                ));

            bundles.IgnoreList.Clear();
        }
    }
}

以下是我的观点:

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>@ViewBag.Title</title>

    @*** SCRIPTS ***@
    @Scripts.Render("~/Scripts/jquery")
    @Scripts.Render("~/Scripts/kendo")
    @Scripts.Render("~/Scripts/validate")
    @Scripts.Render("~/Scripts/google")
    @Scripts.Render("~/Scripts/easyquery")
    @Scripts.Render("~/Scripts/bootstrap")

    @*** STYLES ***@
    @Styles.Render("~/Content/css")
    @Styles.Render("~/Content/jquery")
    @Styles.Render("~/Content/easyquery")
    @Styles.Render("~/Content/kendo")
    @Styles.Render("~/Content/fonts")
</head>

1 个答案:

答案 0 :(得分:0)

ok首先让我们看看bundle配置,你能发布那些看起来像这样的CSS代码

bundles.add(new StyleBundle("~/css/mycss").include(
    "~/folderwherecssis/mycss.css"));

然后你需要确认当你发布这个文件夹路径时存在folderwherecssis / mycss.css

在您的视图中,您使用一段代码(例如

)访问该捆绑包
@Style.Render("~/css/mycss")

根据您发布的内容确定,您可以幽默我并执行以下操作并将您的捆绑包重命名为

bundles.Add(new StyleBundle("~/Styles/css")

等.... 因此,删除内容并将其更改为样式并测试以查看是否有效,您显然必须更改渲染以反映此更改。