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

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