Deploy .net core and angular in less than 5min. No vps setup
Published: 2021-11-15 16:11:52

Nowadays, web hosting companies for .net technologies are more and more rare, but with .net core technology, the problem is not getting any better. I have compiled a list of web hosting companies that support .net and .net core that I will share in another post but today I found smarterasp.net a platform that seems old fashioned but simple in approach and not at all expensive with a free plan (I am not sponsored).In less than 5 min I was able to deploy [NGX.BILL](https://ngxbill.twenty-ninex2.com/) an Angular & .net core application
Here is quickly how I did it

Go to smarterasp.net and create your account.
If you choose their free plan, you have to activate it on the dashboard by providing the requested info before doing anything 

After activating it, click on this icon to access the control panel 
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tfjhys2lcsjuuak475vz.png)

On the left you have your FTP connection information 
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fd0n7tejy2wpffjcvgvz.png)

**Create the database**
Click on database then mssql to create a new SQL Server database 
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/z3i8uncf8ya5houdo8sd.png)

Get the connection string
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qp7e3mcky8wimzq9l9p0.png)

Install dotnet core 3.1 in your local machine: [Download .net core 3.1](https://dotnet.microsoft.com/download/dotnet/3.1)

Use connection string provided in your appsettings.json (take into account your own project) to update the database in order to create the database with tables and default data.


Open a command prompt in the api root folder and navigate to your api project root

If you have a entity framework migrations execute them. this will create database, generate tables and default data inside the database.

```
dotnet ef database update 
```

Run the command below to create the deployment release
```
dotnet publish --configuration Release
```

You release will be at this path : your_dotnet_core_project\bin\Release\netcoreapp3.1\publish

In your_angular_project/src/environments/environment.prod.ts replace the value of with what will be your domain url
```
apiHost: 'http://yourdomain.com/api',
```

Download an install in your local machine the latest node.js: [Link](https://nodejs.org/en/download/)
After nodejs installation, run the command below to install angular cli locally in your machine
```
npm install -g @angular/cli
```

Navigate to the angular root project:
```
npm install
```

Once the installation completed, In the same path, run the command below to generate the release
```
npm run prod
```

This will generate the release at this path: you_angular_project\dist\your_angular_project\
  
Use an FTP File transfert client or download WinSCP to connect to the server: https://winscp.net/eng/download.php

Upload the content of your api your_dotnet_core_project\bin\Release\netcoreapp3.1\publish  to the server and then the content of the client in the dist folder inside the wwwroot folder of your api on the server. 

That's all. Use the url provided to test your site then connect your domain name.

Hope this will help! 

For more see: http://blog.twenty-ninex2.com/