当前位置:网站首页>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>
运行结果如下:
边栏推荐
- .NET应用程序--Helloworld(C#)
- Hash table lookup (hash table)
- How to sort multiple fields and multiple values in sql statement
- The linear table lookup
- How Jin Cang database correctness verification platform installation file
- private package
- 为什么pca分量没有关联
- 软链接引发的物理备份问题
- shell statement to modify txt file or sh file
- 1667. 修复表中的名字
猜你喜欢
随机推荐
Note that Weifang generally needs to pay attention to issuing invoices
How Jin Cang database correctness verification platform installation file
In 2022, you still can't "low code"?Data science can also play with Low-Code!
高项 02 信息系统项目管理基础
lua learning
程序员的七夕浪漫时刻
Is your data safe in this hyperconnected world?
A small tool to transfer files using QR code - QFileTrans 1.2.0.1
View handler stepping record
Linux下常见的开源数据库,你知道几个?
Solve connect: The requested address is not valid in its context
The 22-07-31 weeks summary
The problem of lack of dynamic library "libtinfo.so.5" in ksql application under UOS system
The 20th day of the special assault version of the sword offer
线上MySQL的自增id用尽怎么办?
undo problem
private package
[C language] Detailed explanation of stacks and queues (define, destroy, and data operations)
undo问题
Beidou no. 3 short message terminal high slope in open-pit mine monitoring programme