How to deploy ASP.NET MVC applications to AppHarbor

I’ve already blogged about how awesome AppHarbor is.

So to back up my opinion I’ve decided to write a tutorial about how to deploy an ASP.NET MVC application to AppHarbor.

The application we’ll be deploying will be the ASP.NET MVC Music Store (created by James Senior, Jon Galloway and Scott Hanselman) which uses ASP.NET MVC 3 with Razor syntax and data access via Entity Framework 4.

ASP.NET MVC MusicStore Homepage

Click here to a deployed version of the ASP.NET MVC Music Store running on AppHarbor.

To follow along with the tutorial you’ll need to have the following installed:

If you’re also going to use the ASP.NET MVC Music Store please ensure you change the ..\Views\Shared\_Layout.cshtml to include HTML to indicate the site is a sample available from codeplex and a noindex robots meta tag.

<!DOCTYPE html>
<html>
<head>
    <meta name="robots" content="noindex,nofollow" />
    <title>This is a ASP.NET MVC sample application which can be downloaded at http://mvcmusicstore.codeplex.com</title>
    <link href="@Url.Content("~/Content/Site.css")" rel="stylesheet"
        type="text/css" />
    <script src="@Url.Content("~/Scripts/jquery-1.4.4.min.js")"
        type="text/javascript"></script>
</head>
<body>
 <p style="padding:20px;background-color:#000;color:#FFF;text-align:center">
        This is a ASP.NET MVC sample application which can be downloaded at <a href="http://mvcmusicstore.codeplex.com">http://mvcmusicstore.codeplex.com</a>
    </p>
    <div id="header">
        <h1>
            <a href="/">ASP.NET MVC MUSIC STORE</a>
        </h1>
       <ul id="navlist">
           <li class="first"><a href="@Url.Content("~")" id="current">Home</a></li>
           <li><a href="@Url.Content("~/Store/")">Store</a></li>
           <li>@{Html.RenderAction("CartSummary", "ShoppingCart");}</li>
           <li><a href="@Url.Content("~/StoreManager/")">Admin</a></li>
       </ul>
    </div>
    @{Html.RenderAction("GenreMenu", "Store");}
    <div id="main">
        @RenderBody()
    </div>
    <div id="footer">
        built with <a href="http://asp.net/mvc">ASP.NET MVC 3</a>
    </div>
</body>
</html>

Let’s get started

  1. How to add a ASP.NET MVC solution to a Git repository
  2. How to push a ASP.NET MVC Git repository to AppHarbor
  3. How To Create a SQL Server Database in AppHarbor
  4. How to configure ASP.NET MVC to use a SQL Server database in AppHarbor

I can browse around the store and add things to my cart but can’t log in as an administrator

That’s because you can only have one database per application… something I didn’t know when I started this series.

As AppHarbor doesn’t support file storage (yet) you can’t use the ASPDBNET.MDF database which the music store uses for ASP.NET Membership. See this AppHarbor support entry for more details.

Only One AppHarbor Database Is Allowed



You can of course workaround this by adding membership tables etc. to the existing SQL Server database by via an alternative membership provider which includes using another application hosted on AppHarbor.

Comments

  • http://thezendev.com Dan Martin

    Great series of posts. I just started looking into migrating my blog over to AppHarbor so guides like these are nice if/when I run into any issues.