找不到网页地址:http://localhost:64256/Registration.html

No webpage was found for the web address: http://localhost:64256/Registration.html

我有一个 asp.net 核心 2.1 应用程序,我在其中编写了几个 API。现在在同一个解决方案中,我添加了一个 html 页面来测试 API,

我还将启动浏览器设置更改为 html 页面。现在,当我尝试浏览页面时,浏览器出现错误,

No webpage was found for the web address: http://localhost:64256/Registration.html

我可以这样做吗,我是否缺少任何设置?谢谢!

应将静态文件添加到 wwwroot

在 .net 核心中,您必须启用静态文件。您可以通过在 Startup class.

的 Configure 方法中将 UseStaticFiles() 添加到应用程序构建器来实现

Startup.cs:

public void Configure(IApplicationBuilder app)
{
    app.UseStaticFiles();
}