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

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

SubDomainButtonIf you have a Windows Server shared hosting account that only provides you with one web site, you are not really stuck with having just 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 app

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.
        For example, I created a folder named NewSite inside bookinfo, the folder for my web site.
        sub-folder named NewSite
    • 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.
        App starting folder, NewSite
      • Click the Create button.
        Sub-domain manager
    • Now your new web app will show up in the list of ASP.NET Applications.
      ASP.NET application controls on SAN
  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 new site. The full URL is newsite.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.
      New Site and SubDomain buttons
      • Enter a subdomain name
      • Select the folder you created earlier
      • Click the Create button.
        Sub-domain manager
      • You’re done! You should see your new subdomain show up on the list of My Websites.
        Subsite

Adding a database for your additional web app

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.

Troubleshooting

If you get this error page:

HTTP Error 500.35 - ANCM Multiple In-Process Applications in same Process

It might be caused by a setting in either the web.config file for the sub-domain or for the main site. If the file has these attributes:

modules="AspNetCoreModuleV2"
hostingModel="InProcess"

Then change them to:

modules="AspNetCoreModule"
hostingModel="OutOfProcess"

Reference

A list of database providers available for EF Core
ASP.NET Core hosting models on Windows with IIS
Publish an ASP.NET Core Web App to a Low-Cost Hosting Service

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

Get a Free or Low Cost Domain Name Using Multiple Database Types in an ASP.NET Core Web 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 41 other followers


%d bloggers like this: