Serving Your First File

* Understand how to serve index.html
* Understand how to configure default html page
vs2019/2_Getting_Started
jason.zhu 2021-04-21 23:16:01 +10:00
parent f2cba0c19e
commit 872dc1edba
3 changed files with 20 additions and 4 deletions

View File

@ -4,4 +4,12 @@
<TargetFramework>netcoreapp3.1</TargetFramework> <TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup> </PropertyGroup>
<ItemGroup>
<None Include="wwwroot\index.html" />
</ItemGroup>
<ItemGroup>
<Folder Include="wwwroot\css\" />
</ItemGroup>
</Project> </Project>

View File

@ -21,10 +21,8 @@ namespace DutchTreat
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IWebHostEnvironment env) public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{ {
app.Run(async context => app.UseDefaultFiles();
{ app.UseStaticFiles();
await context.Response.WriteAsync("<html><body><h1>Hello World!</h1></body></html>");
});
} }
} }
} }

View File

@ -0,0 +1,10 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Dutch Treat</title>
</head>
<body>
<h1>Dutch Treat</h1>
</body>
</html>