locked
Deploy MVC to IIS via VS 2015 RRS feed

  • Question

  • User269881539 posted

    I am trying to put my MVC app onto my remote IIS server.

    I created a custom deployment profile in VS 2015 using File System, and in my folder I get the following :

    bin (folder)
    Scripts (folder)
    Views (folder)
    favicon.ico
    packages.config
    PrecompiledApp.config
    Web.config

    I have created a site in IIS and copied this all up but nothings happening I only get 404 errors. 

    Looking for help I see mention of AppRoot and wwwroot folders being created but I don't get these using the deployment in VS anyway.

    I'm sure it should be easier than this?!

    Wednesday, November 11, 2015 12:27 PM

Answers

  • User269881539 posted

    Got this all working

    I had to "include" my content folder into my project firstly - that solved the image issue. 

    I hadn't realised that in local mode debug meant that the scripts / styles get rendered out separately so I added this to my Bundle.config :

    BundleTable.EnableOptimizations = true;

    And I could see it wasn't working properly locally either.

    I changed my css bundle to :

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

    Now that the content folder is included it manages to resolve the bundles properly and creates the minified / bundled version of all file - and now all works well.

    I've also mastered the web.config variances for debug and release and now it all works with a single click on Publish.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, December 2, 2015 11:49 AM

All replies

  • User-166373564 posted

    Hi chilluk,

    This tutorial shows how to deploy an ASP.NET web application to IIS on the  local computer using Visual Studio, more information: ASP.NET Web Deployment using Visual Studio: Deploying to Test

    Regards,

    Angie

    Thursday, November 12, 2015 1:49 AM
  • User269881539 posted

    I've managed to get it to deploy to local IIS on my dev PC - the tutorial then goes on to publish to Azure for staging / production which is inappropriate for me.

    Can't I just copy the locally deployed files, tweak web.config and run on my remote IIS servers? (I have tried this to no avail though!)

    Thursday, November 12, 2015 6:16 AM
  • User-166373564 posted

    Hi Chilluk,

    Thanks for your feedback.

    Can't I just copy the locally deployed files, tweak web.config and run on my remote IIS servers? (I have tried this to no avail though!)

    This discussion describes similar situation like yours, it configures an Internet Information Services (IIS) web server to support web publishing and deployment using the IIS Web Deployment Tool (Web Deploy) Remote Agent Service.

    Hope it helps.

    With regards,

    Angie

    Monday, November 23, 2015 6:05 AM
  • User269881539 posted

    Thanks - it seems the issue was with Web Deploy 3.6 which I had installed - it didn't show anything up in IIS to allow this to be configured. I've stepped down to 3.5 which now shows me the options I was missing. Got as far as setting it all up just got to get port 8172 opened now!

    Monday, November 23, 2015 11:10 AM
  • User269881539 posted

    Hmm still can't get the actual web deploy to work, it says my server is unreachable - got my hosting provider to check firewalls etc and there are no issues.

    Anyway - tried Web Deploy Package instead (this is in VS 2015) - had some success except my images / css / scripts do not render. Instead in my source I have tags with the "bundles" references in, whereas when I debug locally it replaces these with actual links my my content.

    Monday, November 23, 2015 2:37 PM
  • User269881539 posted

    OK I am getting somewhere - I have finally got web deploy working after getting some firewall settings changed.

    This publishes my app to my remote IIS (7) server but when it's up there I get no images / css / client side scripts.

    I can get over the images by selecting to publish the Content directory specifically (is there a way to include this always or is that supposed to be handled separately).

    However I can't get the css / scripts to work as what is rendered still references the bundles (it works locally) like so :

    <link href="/Content/css?v=" rel="stylesheet"/>
    <script src="/bundles/modernizr?v=wBEWDufH_8Md-Pbioxomt90vm6tJN2Pyy9u9zHtWsPo1"></script>
    <script src="/bundles/jquery?v="></script>
    

    Whereas locally I get correctly :

    <link href="/Content/css/style.css" rel="stylesheet"/>
    <script src="/Scripts/modernizr-2.6.2.js"></script>
    <script src="/Scripts/jquery-2.1.4.js"></script>
    

    My bundle.config is as follows :

    public class BundleConfig
    {
    	// For more information on bundling, visit http://go.microsoft.com/fwlink/?LinkId=301862
    	public static void RegisterBundles(BundleCollection bundles)
    	{
    		bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
    					"~/Scripts/jquery-{version}.js","~/Scripts/menus.js"));
    
    		bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include(
    					"~/Scripts/jquery.validate*"));
    
    		// 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/css/style.css"));
    	}
    }

    And I reference in my _Layout as follows :

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

    If it works locally and not remotely I assume there is something I am missing in the build / publish stage? Or some sort of config change required?

    Thanks

    Wednesday, November 25, 2015 2:31 PM
  • User269881539 posted

    Got this all working

    I had to "include" my content folder into my project firstly - that solved the image issue. 

    I hadn't realised that in local mode debug meant that the scripts / styles get rendered out separately so I added this to my Bundle.config :

    BundleTable.EnableOptimizations = true;

    And I could see it wasn't working properly locally either.

    I changed my css bundle to :

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

    Now that the content folder is included it manages to resolve the bundles properly and creates the minified / bundled version of all file - and now all works well.

    I've also mastered the web.config variances for debug and release and now it all works with a single click on Publish.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, December 2, 2015 11:49 AM