ASPNETCore 1.x Postgres Sample

by heroku-softtrends


.NET Core 1.0 Sample code with Heroku Postgres Support

(Heroku Button with ASP.NET Core + Postgres Sample)

This uses the .Net Core Buildpack provided by Softtends and adds full support for Heroku Postgres

We've made some big updates in this release, so it’s important that you spend a few minutes to learn what’s new.

You've created a new ASP.NET Core MVC project. Learn what's new

You need to make the following changes in your Program.cs and project.json to deploy on Heroku
In Program.cs

  • Add UseUrls method and pass args[0] as parameter to start your app. Because Heroku web dyno will start with dynamic port after sucessful deployment. We need to use the same port in code behind also then only your app will start and listen on that port else dotnet runtime will set default port 5000. Thereby we pass port number as parameter with url in Procfile

public static void Main(string[] args {
var host = new WebHostBuilder() .UseKestrel() .UseContentRoot(Directory.GetCurrentDirectory()) .UseIISIntegration() .UseStartup() **.UseUrls(args[0])** .Build();

In project.json

  • Add a new property called "outputName": "Your_ProjectName" in buildOptions
  • Remove scripts section. It has prepublish and postpublish actions which are not needed

You can deploy this ASP.Net MVC website on Heroku server by clicking below button


This application consists of:

  • Sample pages using ASP.NET Core MVC
  • Gulp and Bower for managing client-side libraries
  • Theming using Bootstrap

How to


Run & Deploy

We would love to hear your feedback