ASP.NET CORE React project actual combat (1)

asp.net-core-react

asp.net core react

Introduction< /h2>

  1. Development dependent environment
.NET Core SDK (reflecting any global.json): 
Version: 2.2.300

Runtime Environment:
OS Name: Mac OS X

Host (useful for support):
Version: 2.2.5

node -v
v10.16.0
  1. Development language
    asp.net core
    react

  2. Development tools< br> vscode

Development process

  1. Create sln project solution “Sln is not necessary to create but Created to be friendly to smart prompts”
    dotnet new sln

  2. Organize the project
    In order to be more fashionable, I have a bed frame in the hierarchical directory alongside sln A src folder is used to manage the source code
    mkdir src
  3. Enter the src directory and create a react web application named web
    cd src< /code>
    dotnet new react -o web
  4. Go back to the project root directory and add the newly added web project to the sln project solution file
    dotnet sln add src/web/web.csproj
    "This must be added"
    Our current directory structure is like this
.
├── LICENSE
├── README.md
├── asp.net-core-react.sln
└── src
└── web
├── ClientApp
├── Controllers
├── Pages
├── Program.cs
├── Properties
├── Startup.cs
├── appsettings.Development.json
├── appsettings.json
├── obj
└── web.csproj

7 directories , 8 files
  1. Start the project -p Specify the project startup file src/web There is Program.cs in the startup project file for us
    dotnet run -p src/web/< /code>
  2. Project start ok

Share pictures

  1. Browse web/ClientApp/package.json
"scripts": {
"start": "rimraf ./build && react-scripts start",
"build": "react-scripts build",
"test": "cross-env CI=true react-scripts test --env=jsdom",
"eject": "react-scripts eject",
"lint": "eslint ./src/"
}

Scripts integrates several commands to start React this project or build this project needs to add npm before starting this project
npm start
npm build
n pm test
...
The execution directory should be in the ClinetApp folder

  1. build react project

Share pictures

  1. Release project
    Create a release folder at the same level as sln Used to store release files
    dotnet publish -c release -o ../../release/
    Publish the project

Share a picture

  1. Execute the release file
    dotnet release/web .dll
  2. Tweets about environment variable settings
    https://docs.microsoft.com/zh-cn/aspnet/core/fundamentals/environments?view=aspnetcore-2.2< /li>

Project has been pushed to GitHub

Address:
https://github.com/TopGuo/asp.net- core-react

Second Chapter

Semi-finished product...no time to do it ... Later improvements

This demo is quite predictable

  1. There are pits between c# md5 encryption and decryption and js
  2. Use another The method uses dapper
  3. ... a purpose to experience the effects of .net core and react
    current project performance

share picture

Share a picture

Share a picture

share picture

Leave a Comment

Your email address will not be published.