简体   繁体   English

ASP.NET 核心空白应用startup.cs

[英]ASP.NET Core blank application startup.cs

I am trying to follow along with a pluralsight course creating in VStudio 2019 a blank ASP .NET core project with an empty project template.我正在尝试在 VStudio 2019 中创建一个带有空项目模板的空白 ASP .NET 核心项目的复数视觉课程。

My startup.cs differs significantly from the course in that it does not have我的 startup.cs 与课程有很大不同,因为它没有

app.UseRouting() and app.useEndpoints() app.UseRouting() 和 app.useEndpoints()

my startup.cs basically has only app.Run()我的 startup.cs 基本上只有 app.Run()

I recreated project 2 times to make sure I followed directions, I made sure my.Net Core and CLR were the most recent versions.我重新创建了 2 次项目以确保我遵循指示,我确保我的.Net Core 和 CLR 是最新版本。 Google search revealed no useful information.谷歌搜索没有发现有用的信息。 I assume I am missing something fundamental.我想我错过了一些基本的东西。 I made sure I created like course did use blank solution and empty project template.我确保我创建的课程确实使用了空白解决方案和空白项目模板。

My newly created solution runs fine so I presume there is some "version problem" or something changed in terms of the way things are done?我新创建的解决方案运行良好,所以我认为存在一些“版本问题”或在处理方式方面发生了一些变化?

Thanks much非常感谢

Sounds like you have done something wrong as if you look at the doco听起来你做错了什么,好像你在看doco

All ASP.NET Core templates include routing in the generated code.所有 ASP.NET 核心模板在生成的代码中都包含路由。 Routing is registered in the middleware pipeline in Startup.Configure.路由在 Startup.Configure 的中间件管道中注册。

 public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseRouting(); app.UseEndpoints(endpoints => { endpoints.MapGet("/", async context => { await context.Response.WriteAsync("Hello World;"); }); }); }

This is with Core 3.1 - check the verson of Core app you are creating.这是 Core 3.1 - 检查您正在创建的 Core 应用程序的版本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM