Home » Categories » Multiple Categories

How to Deploy and host .Net Core 2 and Angular 6 app

Normally, you will have two separate projects, i.e. one for .NET Core Web API 2.0 and the other one is Angular 6. On our Windows environment, you will find a root folder called httpdocs



Problem: 

If you simply deploy the contents of the folder inside dist to the root folder httpdocs on server, there will be an error message, which states that "it cannot find any page", but the API still works.

If you transfer the whole folder inside httpdocs and set server Host setting to define document root to the folder:


It will find the index.html and show me my landing page. However then API won't work.

If you leave it as is and change the document root back to httpdocs ( where the API files are ), but push the index.html from httpdocs/website to httpdocs ( in this case I also edit index.html to point to website folder for resources etc ) in the hope it will find it ( server IIS setting )



Solution:

1) Please add 2 lines of code in Configure method of Startup.cs in the API

app.UseDefaultFiles();
app.UseStaticFiles(); // For the wwwroot folder

Where according to MSDN, "With UseDefaultFiles, requests to a folder search for: index.html"

2) Please manually add wwwroot folder which for some reason was not generating upon publishing command for your API project.

3) In that folder, please copy all contents of my dist/website angular publish files


Now, it should work fine.

If there is any issue, please ensure you raise a ticket via our Help Desk System

Attachments Attachments
There are no attachments for this article.
Related Articles RSS Feed
Domain Name Server (DNS) Amplification Attack
Viewed 9475 times since Wed, Oct 15, 2014
I forgot my Help Desk Account password. What should I do?
Viewed 7109 times since Mon, May 7, 2012
I cannot browse to my site via the IP Address directly. What is wrong?
Viewed 4562 times since Mon, May 7, 2012
How do I redirect a subdomain to a subdirectory?
Viewed 4025 times since Tue, May 1, 2012
Monitoring Tools For Windows
Viewed 934 times since Wed, Jul 13, 2022
Have you supported Crystal Report for VS 2010 (v13)?
Viewed 2901 times since Tue, May 1, 2012
How do I send an email from my ASP.NET website by using SMTP Authentication?
Viewed 6497 times since Tue, May 1, 2012
How can I publish my website to your server?
Viewed 7699 times since Mon, Apr 30, 2012