且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

路由不适用于自托管 Web API

更新时间:2023-02-15 22:10:48

这很难追查,但问题归结为 .csproj 中的这个:

This was rather difficult to track down, but the problem boils down to this in your .csproj:

<Project Sdk="Microsoft.NET.Sdk">

在构建 Web 应用程序时,您需要改为引用 Web Sdk,如下所示:

As you are building a web application, you need to instead reference the Web Sdk, as follows:

<Project Sdk="Microsoft.NET.Sdk.Web">

我设法通过这个小改动重现并解决了您的问题.

I managed to reproduce and fix your issue with this small change.