Hosting Multiple ASP.NET Core Sub-Sites on a Single Site Hosting Account

December 4, 2019 at 9:19 am Leave a comment

If you have a Windows Server, shared hosting account that only provides you with one web site, you are not really stuck with just having one site. In most cases, you can add additional sites by putting them in sub-folders (aka sub-directories) of the main site. For example, SmarterASP.NET has a $2.95 a month plan that gives you only one web site. But you aren’t actually limited to having just one web site since you can add any number of additional ASP.NET or ASP.NET Core web applications in sub-folders.

How to add an additional web application

Here are the steps to follow on Smarter ASP.NET (the process will be similar on other shared hosting services):

  1. Create a sub-folder and set it as an application starting point.
    • Click on the Control Panel button for your account.
    • Click on the Files button.
      • Create a new folder within your existing site folder.
    • Click on the Websites button.
      • Click on the Manage Website link for your site.
      • Click on the Create .Net App tab.
      • At the bottom of the page, under the title Create New ASP.NET Application, click on the folder icon and choose the new folder you just created.
      • Click the Create button.
        You’re over half-way to finishing!
  2. Create a subdomain pointer for your new web app.
    A subdomain is just an additional name added at the beginning of your domain name and separated by a dot. For example, one of my domains is probird.online. I have added a subdomain named exercise6a. The full URL is exercise6a.profbird.online.

    Here are the steps to add a subdomain that points to your new web app.

    • Click on the Websites button.
    • Click on the +Sub Domain button.
      • Enter a subdomain name
      • Select the folder you created earlier
      • Click the Create button.
        You’re done!

How to add a database for your application

Most shared hosting services offer both one MySQL and one SQL Server database with their lowest cost plan. This allows you to have databases for two web sites. Entity Framework (EF)  Core has database providers (these are Nuget packages that provide a connection from EF to a particular type of database) for both types of database–so two of your sites can have their own database.

If you want to have even more sites that use databases, you can use either Microsoft Access or SQLite. Most IIS based shared hosting services provide unlimited Access databases. In addition, you can add the SQLite Database Management System to your web application just by dropping the sqlite3.dll file in your application’s folder. There are Access and SQLite database providers available for EF Core–so you can add as many databases as you like!

This all sounds great, but it can be a little tricky setting your app up to use a different type of database on the hosting service than the one it uses on your development machine. For example, if your development machine is using SQL Server LocalDB (the default development database for Visual Studio), and you set up a web app using MySQL on the hosting service, then how do you code your app to use a different database provider for each of the two places it runs? I’ll address that in my next post.

Reference

A list of database providers available for EF Core

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

Get a Free or Low Cost Domain Name Using Multiple Database Types in an ASP.NET Core App

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 40 other followers


%d bloggers like this: