Deployed Version of MVC Site Not Working

143 views Asked by At

I have an MVC web application (.csproj) which works fine in Visual Studio, along with other projects in the solution. However, when I deploy it, either using Subversion & TeamCity, or even using Visual Studio's Publish wizard (to a local folder), it builds successfully, but it doesn't function properly.

For example, I noticed that some CSS files were not getting loaded to the page. After looking at Chrome Developer Tools as well as Fiddler, it turns out that requests were not even being made to request the particular file. In the version of the site that works (i.e., in Visual Studio), the css file is requested from /App_Start/BundleConfig.cs. It turns out that the entire folder is not even being deployed. Manually copying over that folder didn't solve the issue either.

What's going on?

Thanks,

UPDATE

Here's my 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();
        }
    }
}

And here's my view:

<!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

There are 1 answers

0
Paul Coan On

ok firstly lets look at the bundle config, can you post that code it should look something like this for CSS

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

Then you need to confirm that when you publish this folder path exists folderwherecssis/mycss.css

On your view are you accessing the bundle with a piece of code like this

@Style.Render("~/css/mycss")

ok based on what you have posted can you humour me and do the following and rename you bundles to be like this

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

etc.... So get rid of the Content and change it to Styles and test to see if this works, you would obviously have to change your render as well to reflect this change.