Publishing an ASP.NET Core Web App to a Low-Cost Windows Hosting Service

February 18, 2019 at 5:05 pm 7 comments

You’re developing an awesome ASP.NET Core web app and need to give it a home on the internet. If you expect your app to experience light or medium traffic1, you can use an inexpensive shared Windows Server, IIS hosting provider like SmarterASP.NET. Of course, alternatively, you could publish your site to a low cost Linux VPS hosting service, like Linode, but that could cost a bit more and configuring the server will be quite a bit more work.

These are the steps we’ll follow to publish an ASP.NET Core web app:

  1. Create an account
  2. Set up a database
  3. Prepare your app for production
  4. Deploy your web app!

1. Create an account on the hosting service

Smarter ASP.NET offers a free 60 day account without a credit card. There are a couple of caveats though:

  • The free account requires a phone number for an SMS verification code.
  • For 60 days free, they supposedly require you to post to Facebook and Google+.
    Although, I didn’t do either and I still got 60 days free!

Here are some tips when creating your account:

  • You can give your web site a name other than site1, I named mine home.
  • Select ASP.NET as the account type
  • Test the account by going to the URL for the temporary domain name. For example: (not a real URL). You should see a page showing the default document.

2. Create a Database

  1. In the Smarter ASP.NET control panel, create a MSSQL database
    • I chose MSSQL 2016.
    • I named it the same as my web site–just so it would be easy to remember.
    • Example database name and info:
      Username: DB_A452B1_home_admin
  2. Get the connection string by clicking on “Connection String Examples” at the bottom of the database page in the control panel
    • Choose an ASP.NET connection string. Mine looks like this:
      “Data;Initial Catalog=DB_A452B1_home;User Id=DB_A452B1_home_admin;Password=YOUR_DB_PASSWORD;”
  3. Check the database using one of these tools:
    • The online database manager: Webbase MS SQL Server Manager
    • Microsoft SQL Server Management Studio
    • Visual Studio’s Server Explorer
    • DBeaver, a useful cross-platform free, open-source database manager.

3. Prepare the Web App

There are two ways you can deploy your app2:

  • Framework-dependent deployment
    The .Net Core run-time package is installed on the server and so your app uses the run-time environment that is already there.
  • Self-contained deployment
    The .NET Core run-time package is deployed along with your app.

We are going to use the self-contained approach since it can be tricky to try to change the build settings of your project in Visual Studio so that it is targeting one of the versions of .NET Core that is installed on the hosting service’s servers. Because of that there isn’t much to do in this step except to configure the database connection string for the production server

Configuring the production connection string

  • Add two new appsettings files to your project:
    • appsettings.development.json
      Move the connection strings for your local machine to this file.
    • appsettings.production.json
      • Put the connection string for the hosted database here. Put xxxx or some other place-holder in place of the password. Be sure the connection string has the same name as one that is loaded in the Startup class
      • Example:
        "ConnectionStrings": {
        "MsSqlConnection": "Data Source=SQL5004,1433;
        Initial Catalog=DB_A451DA_BookInfo2;User
      • Put a copy of the same production connection string in your default appsettings.json. This is only so that the Visual Studio Publish wizard will see it.
  • Set your local machine’s ASPCORENET_ENVIRONMENT environment variable to Development. The environment variable on the production server will have already been set to Production. For instructions for setting environment variables, see Set the Environment.
  • Note: The Visual Studio Publish tool won’t recognize connection strings unless they are in a top-level JSON object named “ConnectionStrings”.

When you are running your app on your development machine, the default appsettings.json and appsettings.development.json will be read. When your app runs on the production machine, appsettings.json and appsettings.production.json will be used.

4. Deploy the Web App

There are several different methods you can use to deploy your app using the Visual Studio Publish wizard:

  • WebDeploy
    This is a proprietary Microsoft protocol for uploading files to a server. It’s supported by SmarterASP.NET and is a good option.
  • FTP
    This, of course, is a universally supported protocol and is another good option.
  • File System
    This option simply puts the output files in a folder of your choice on your machine. From there you can manually copy the files to the server.

We will use the File System option. The reasons for this are:

  • The Basic account on SmarterASP.NET doesn’t support WebDeploy (although the free trial does).
  • Some ISPs or company firewalls block WebDeploy.
    (At the college where I teach, the network firewall blocks both WebDeploy and FTP.)
  • The FTP option in Visual Studio 2017 appears to be buggy! Sometimes it says it uploaded the files successfully when actually it hasn’t.

A. Create a publish profile

Here are the steps to create a publish profile for your app:

  1. Start by right-clicking on your project name in the Visual Studio Solution Explorer and selecting Publish.
  2. Click on Configure and in the connection dialog box select File System as the publish method and enter the location where you want to put the output files (your location doesn’t need to be the same as mine).


  1. Select Settings and enter settings similar to those in the image below. Here are some things that may be different:
    • Target Framework–yours may be different. This will be set automatically depending on the target in your Visual Studio project
    • Databases, connection strings–the connection string names will come from your project and will likely be different from mine. Your connection strings will certainly be different! Be sure to enter the password. I intentionally left mine as xxxxxx for the screen-shot.
    • Entity Framework Migrations–Copy the connection string from Databases, with the password, and put it here. When you run the Publish wizard it will connect to your online database and apply the latest migration. This is equivalent to running dotnet ef database update on your local machine.
      • Be sure your connection string contains the full URL for your online database, for example:


B. Publish the app

  1. Click Save, then click on Publish and your app will be published to the folder your chose.
  2. Now you need to copy the files to your online server. You can do that using one of two ways:
    • Use the File Manager that is part of the SmarterASP.NET control panel.
      • On your local machine, zip all the files in the folder where you published your site. Just zip the files, not the enclosing folder.
      • In the SmarterASP.NET file manager:
        • Upload the zip file to your home folder.
        • Unzip the files.
    • Use an FTP client like FileZilla to upload the files

C. Run your app!

Point your browser at the URL for your site and you should see your home page!

5. Keep Your Web App “Alive”

You may notice that if you don’t access your site for a while (half a day), it will act like it has become dormant and it will take a minute or more to respond when you try to open it in a browser. Here are two solutions to that problem:

  • Use the free Down Notifier service to “ping” it every 10 or 20 minutes so that it stays alive.
  • In the SmarterASP.NET control panel, go to the “Advance” settings page and look for “Schedule Tasks”, on that page, enter the URL of your web site as a task and set it to run every 20 minutes.


Basic troubleshooting

If you see an error page instead of your home page, here are some things to check:

  • Did your database tables get created by the Visual Studio Publish wizard? You can check this by using the SmarterASP.NET database viewer to see if your database has the right tables.
    • If the tables weren’t created, you can check the connection string in the publish wizard (make sure it has a password) and try publishing again.
    • Some ISPs block the database connection. If that is the case, you can upload your local database to SmarterASP.NET. To do this, in the database control panel, select attach database file.
  • Did appsettings.production.json get uploaded to the home folder of your web site?You can check this using the File manager in the SmarterASP.NET Control panel.
  • Does appsettings.production.json contain the correct connection string and database password? This file should have been updated by the publish wizard. You can check it’s contents by using the File Manager in the SmarterASP.NET control panel to download it, or download it using an FTP client.
  • Did web.config get uploaded to the home folder of your web site?
    This file is required to configure IIS to run an ASP.NET Core web site. The file was generated by the Publish wizard.

Advanced troubleshooting

You can do further troubleshooting by enabling error logging from your ASP.NET Core web app. You need to do this:

  • Edit web.config to set stdoutLogEnabled to true, like this:
        <aspNetCore processPath=".\GoodBookNook.exe" stdoutLogEnabled="true" stdoutLogFile=".\logs\stdout" />
  • Ensure that the folder containing your web site has read/write permissions. (IIS will create a logs sub-folder there.)

Now, turn off your site off and turn it back on and refresh your home page in your browser. Check the logs folder and see if there is now a log file there. If there is, download it and see what kind of clues are in it.


1I’ve done load testing using JMeter on one of my sites on SmarterASP.NET. I ran a test with 100 simulated concurrent users and got an average latency of 50ms and an average through put of 78 pages per second. This is surprisingly good performance for a $2.95 a month plan, and was probably due to using the free CloudFlare CDN provided by SmarterASP.NET.

1For more information on different ways to deploy ASP.NET Core web apps, refer to this article in the Microsoft Documentation: Deploy .NET Core apps with Visual Studio

Entry filed under: ASP.NET Core, C#, Programming, Web Development. Tags: , , , .

ASP.NET Core Razor Pages – Part 1 Get a Free or Low Cost Domain Name

7 Comments Add your own

  • 1. Get a Free or Low Cost Domain Name | Bird's Bits  |  October 31, 2019 at 12:37 pm

    […] my previous post, I showed you how to set up low cost hosting for your ASP.NET Core web site on SmarterASP.NET. Now that your site is up and running, you probably want to get a domain name […]

  • 2. Bahrom  |  November 10, 2019 at 4:58 pm

    Yesterday, 11/9/2019, all my web sites on SmarterASP.NET went down. Today they posted this message:

    Your hosting account was under attack and hackers have encrypted all your data. We are now working with security experts to try to decrypt your data and also to make sure this would never happen again. Please stay tune for more info. Please know that we are getting thousands of messages in our email and live chat and we don’t have enough staffs to reply them all. We will continue to put out notices on our Facebook page and page, Please check back soon.

    There is more information in this article: ZDNET:Major ASP.NET Hosting Provider Infected by Ransomware

    I am hoping that they will be able to restore my web sites and databases. I’ll let you know what happens.

  • 3. Bahrom  |  November 20, 2019 at 8:37 pm

    My sites were all restored on Nov. 11th. The longest any site was down was about 48 hours.

  • […] A list of database providers available for EF CoreASP.NET Core hosting models on Windows with IISPublish an ASP.NET Core Web App to a Low-Cost Hosting Service […]

  • 5. William Ho  |  August 23, 2020 at 11:44 pm

    Company has no customer care at all. For the last 14 hours at least, the hosting, email, ticket system and support phone service has been unavailable, totally down, all my web sites have been down, my email, my customers email, my customers web sites, all, down, no way to contact the. company, calling customer support vets you a recording saying that no one is available, call back later. This is not the first time this has happened. I have moved back to Asphostportal again. Although price quite higher but the service is reliable

    • 6. Bahrom  |  December 2, 2020 at 6:35 pm

      I agree that there are shortcomings in SmarterASP.NET’s customer service and reliability, but my experience hasn’t been too bad. Most of the time I get quick responses to my technical support requests and down-time has been pretty minimal. But, for hosting my client’s sites, I use WinHost which is more reliable and has excellent customer support. I’ve been using their service since 2009 and never had any problems.

  • 7. Bahrom  |  December 26, 2020 at 4:55 pm

    Smarter ASP.NET is is offering a 60% discount on new shared hosting accounts using this coupon code: xmas60
    This code is good through Jan. 5th, 2021


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Trackback this post  |  Subscribe to the comments via RSS Feed

Bird’s Bits

Computers, software & the Internet

Enter your email address to follow this blog and receive notifications of new posts by email.

Join 41 other followers

%d bloggers like this: