当前位置:网站首页>ASP.NET application--Hello World
ASP.NET application--Hello World
2022-08-05 03:06:00 【DXB2021】
安装 .NET and create the first Web 应用程序.
On-premises provisioning wizard and provisioning agent:
下载.NET SDK(软件开发安装包)
打开Windows PowerShell,输入命令行dotnet.
dotnet
运行结果如下:
如果安装成功,则会看到类似于以上内容的输出.
创建应用
在命令提示符,运行以下命令以创建应用:
dotnet new webapp -o MyWebApp --no-https -f net6.0
What does this command mean?
dotnet new
The command will create a new application.
webApp
The parameter selects the template to use when creating the app.-o
参数会创建名为MyWebApp
的目录,用于存储应用.--no-https
The flag specifies that it is not enabled HTTPS.-f
参数指示你正在创建 .NET 6 应用程序.
Which files were created?
已在 MyWebApp
Create multiple files in the directory,To provide you with simple to run Web 应用程序.
Program.cs
Contains application startup code and middleware configuration.Pages
The directory contains some sample web pages for the application.MyWebApp.csproj
Some project settings are defined,For example to be oriented .NET SDK 版本.Properties
目录中的launchSettings.json
file defines different configuration file settings for the local development environment.It is automatically assigned when the project is created 5000-5300 and save it on this file.
运行应用
在命令提示符中,Navigate to the directory created in the previous step:
cd MyWebApp
然后,运行以下命令:
dotnet watch
Wait for the app to show listening http://localhost:<port number>
and wait for the browser to start at that address.
Congratulations on building and running your first one .NET Web 应用!
选择Ctrl+C,to stop the application at any time.
编辑代码
编辑代码
Open in any text editor at Pages
目录中的 Index.cshtml
文件.
before entering the code:
代码如下:
@page
@model IndexModel
@{
ViewData["Title"] = "Home page";
}
<div class="text-center">
<h1 class="display-4">Welcome</h1>
<p>Learn about <a href="https://docs.microsoft.com/aspnet/core">building Web apps with ASP.NET Core</a>.</p>
</div>
After entering the code:
代码如下:
@page
@model IndexModel
@{
ViewData["Title"] = "Home page";
}
<div class="text-center">
<h1>Hello,world!</h1>
<p>The time on the server is @DateTime.Now</p>
</div>
运行结果:
代码如下:
@page
@model IndexModel
@{
ViewData["Title"] = "Home page";
}
<div class="text-center">
<h1 class="display-4">Welcome</h1>
<h1>Hello, world!</h1>
<p>The time on the server is @DateTime.Now</p>
<p>Learn about <a href="https://docs.microsoft.com/aspnet/core">building Web apps with ASP.NET Core</a>.</p>
</div>
运行结果如下:
边栏推荐
- 沃谈小知识 |“远程透传”那点事儿
- QT MV\MVC结构
- 基于左序遍历的数据存储实践
- leetcode - symmetric binary tree
- Error: Not a signal or slot declaration
- 2022高处安装、维护、拆除考试题模拟考试题库及在线模拟考试
- How to solve the error cannot update secondary snapshot during a parallel operation when the PostgreSQL database uses navicat to open the table structure?
- OpenGL 工作原理
- Linux下常见的开源数据库,你知道几个?
- post-study program
猜你喜欢
金仓数据库如何验证安装文件平台正确性
大像素全景制作完成后,推广方式有哪些?
Regular expression to match a certain string in the middle
mysql can't Execute, please solve it
Cloud Native (32) | Introduction to Platform Storage System in Kubernetes
毕设-基于SSM房屋租赁管理系统
Step by step how to perform data risk assessment
How to sort multiple fields and multiple values in sql statement
.NET应用程序--Helloworld(C#)
使用二维码传输文件的小工具 - QFileTrans 1.2.0.1
随机推荐
One hundred - day plan -- -- DAY2 brush
链表的简单描述及代码的简单实现
undo problem
Gantt chart is here, project management artifact, template is used directly
rpc-remote procedure call demo
tree table lookup
mysql没法Execute 大拿们求解
QStyle平台风格
torch.roll()
The linear table lookup
1527. Patients suffering from a disease
21天学习挑战赛(2)图解设备树的使用
Native js realizes the effect of selecting and canceling all the multi-select boxes
post-study program
Flink 1.15.1 Cluster Construction (StandaloneSession)
Is your data safe in this hyperconnected world?
mysql tree structure query problem
Matlab drawing 3
The design idea of DMicro, the Go microservice development framework
1873. 计算特殊奖金