ASP.net on centos with dotnet core

好久沒有接觸.NET, 老是說不行不能非windows部署,我不相信,官網多說可以的
https://dotnet.microsoft.com/learn/aspnet/hello-world-tutorial/install
左邊選好操作系統,不然認當前系統,自動Mac了。。。

選Centos 7

推薦install the ASP.NET Core runtime, as it includes both .NET Core and ASP.NET Core runtimes.
參考https://docs.microsoft.com/en-us/dotnet/core/install/linux-package-manager-centos7#install-the-aspnet-core-runtime
sudo rpm -Uvh https://packages.microsoft.com/config/centos/7/packages-microsoft-prod.rpm
sudo yum install aspnetcore-runtime-3.1
sudo yum install dotnet-sdk-3.1
、、不同版本的處理、、
ASP.NET Core 2.x is supported on .NET Framework versions that implement .NET Standard 2.0:
version
The version of the SDK or runtime to install. This article will always give the instructions for the latest supported version. Valid options are any released version, such as:
3.0
2.2
2.1
Examples
Install the .NET Core 2.2 SDK: dotnet-sdk-2.2
Install the ASP.NET Core 3.0 runtime: aspnetcore-runtime-3.0
Install the .NET Core 2.1 runtime: dotnet-runtime-2.1
跑命令,需要SDK 開發包
dotnet new webApp -o myWebApp --no-https
cd myWebApp
項目根據項目模板生成
The template “ASP.NET Core Web App” was created successfully.
This template contains technologies from parties other than Microsoft, see https://aka.ms/aspnetcore/3.1-third-party-notices for details.
試着跑起來項目
dotnet run
看下輸出內容
Application started. Press Ctrl+C to shut down.
info: Microsoft.Hosting.Lifetime[0]
Hosting environment: Development
info: Microsoft.Hosting.Lifetime[0]
Content root path: /root/zdev/myWebApp
在這裏插入圖片描述
curl http://localhost:5000
輸出頁面內容,但是外面訪問不到,修改配置中的服務訪問URL地址,改爲IP地址,外部可訪
myWebApp/Properties/launchSettings.json

Dotnet run啓動時候還是挺消耗CPU的
接下來可以簡單瞭解下coding

Vim Pages/Index.cshtml
@page
@model IndexModel
@{
ViewData[“Title”] = “Home page”;
}

Welcome @DateTime.Now

Learn about building Web apps with ASP.NET Core.

接下來更多的要學習的話,熟悉下Razor Pages in ASP.NET Core

https://docs.microsoft.com/en-us/aspnet/core/tutorials/razor-pages/razor-pages-start?view=aspnetcore-3.1&tabs=visual-studio

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章