先决条件(开发配置二选一):
-
带有 ASP.NET 和 Web 开发工作负载的Visual Studio
-
Visual Studio Code
- Visual Studio Code
- 用于 Visual Studio Code 的 C#(最新版本)
- .NET 7.0 SDK
创建Web应用
-
visual studio
ctrl + F5 (开始执行,不调试)
-
VS Code
在代码工作区间文件夹路径下打开终端运行下面的命令
dotnet new mvc -o MvcMovie
code -r MvcMovie
通过运行以下命令来信任 HTTPS 开发证书:
dotnet dev-certs https --trust
PS D:\Colde\asp.net\vs_code_workspace\MvcMovie> dotnet dev-certs https --trust
Trusting the HTTPS development certificate was requested. A confirmation prompt will be displayed if the certificate was not previously trusted. Click yes on the prompt to trust the certificate.
Successfully trusted the existing HTTPS certificate.
PS D:\Colde\asp.net\vs_code_workspace\MvcMovie>
编译运行
PS D:\Colde\asp.net\vs_code_workspace\MvcMovie> dotnet build
MSBuild version 17.6.3+07e294721 for .NET
正在确定要还原的项目…
所有项目均是最新的,无法还原。
MvcMovie -> D:\Colde\asp.net\vs_code_workspace\MvcMovie\bin\Debug\net7.0\MvcMovie.dll
已成功生成。
0 个警告
0 个错误
已用时间 00:00:00.63
PS D:\Colde\asp.net\vs_code_workspace\MvcMovie>
PS D:\Colde\asp.net\vs_code_workspace\MvcMovie> dotnet run
正在生成...
info: Microsoft.Hosting.Lifetime[14]
Now listening on: http://localhost:5290
info: Microsoft.Hosting.Lifetime[0]
Application started. Press Ctrl+C to shut down.
info: Microsoft.Hosting.Lifetime[0]
Hosting environment: Development
info: Microsoft.Hosting.Lifetime[0]
Content root path: D:\Colde\asp.net\vs_code_workspace\MvcMovie