Developing ASP.NET Core App in Visual Studio and Deploying on Simple Application Server

Quick FAQ

Developing Example Application

Prerequisites

Create ASP.NET core project from template

Edit and Change Code

<a asp-page="/Index" class="navbar-brand">Alibaba SAS Demo</a>

Run Application

Publish Example Project for Deployment

Prepare the Web Application

<RuntimeHostConfigurationOption Include="System.Globalization.Invariant" Value="true" />
app.UseForwardedHeaders(new ForwardedHeadersOptions
{
ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto
});
public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseUrls("http://*:5000")
.UseStartup<Startup>();

Publish Project as Self-Contained Application

Publish from Visual Studio

Publish from Command Prompt

dotnet publish -c release -r linux-x64

Create a Simple Application Server Instance on Alibaba Cloud

Log in and Select Simple Application Server

Setup Server Configuration

Deploy application on simple application server

Create Password

Install Prerequisites on Server

sudo yum -y update
sudo yum install nginx
sudo service nginx start
systemctl status nginx
sudo yum update
sudo yum install nano
sudo yum update
sudo yum install supervisor

Deploy Application

chmod +x alibabadotnetcore
./alibabadotnetcore

Configure Nginx

sudo cp /etc/nginx/nginx.conf /etc/nginx/nginx.conf.bak
sudo nano /etc/nginx/nginx.conf
location / {
proxy_pass http://localhost:5000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection keep-alive;
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
sudo nginx –t
sudo nginx -s reload
cd dotnetappdir/publish
./alibabadotnetcore

Final Steps

nginx error!
The page you are looking for is temporarily unavailable. Please try again later.
cp -r ~/dotnetappdir /var
touch /var/dotnetappdir/startscript
nano /var/dotnetappdir/startscript
#!/bin/sh
cd /var/dotnetappdir/publish
./alibabadotnetcore
chmod +x /var/dotnetappdir/startscript
nano /etc/supervisord.conf
[program:start_script_alibabadotnetcore]
command=/var/dotnetappdir/startscript
autostart=true
autorestart=true
stderr_logfile=/var/dotnetappdir/alibabadotnetcore.err.log
stdout_logfile=/var/dotnetappdir/alibabadotnetcore.out.log
sudo supervisord -c /etc/supervisord.conf

Conclusion

--

--

--

Follow me to keep abreast with the latest technology news, industry insights, and developer trends. Alibaba Cloud website:https://www.alibabacloud.com

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Send Email Using SendGrid Email Service with an Attachment

Optimizing React App Performance

Setting up First End Point

EOS Amsterdam WAX Guild Showcase Update

OAuth 2.0- An Overview and Simple Guide to build an Sample Application

How Operating Systems Work: 10 Concepts you Should Know as a Developer

Microservices can help you manage legacy code

Cloud Native Databases on Docker and Kubernetes

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Alibaba Cloud

Alibaba Cloud

Follow me to keep abreast with the latest technology news, industry insights, and developer trends. Alibaba Cloud website:https://www.alibabacloud.com

More from Medium

Docker deep level with architecture — part 1

Continuous Integration (CI) with Github Action

Azure IoT Edge with proxy and Certificate

Introduction to CI pipelines on Github

Two people looking at code on a Silver Macbook Pro https://www.pexels.com/@divinetechygirl?utm_content=attributionCopyText&utm_medium=referral&utm_source=pexels