[英]ASP.NET Core API Swagger - No webpage was found for the web address: https://localhost:44358
[英]after upgrade to .net core 3.0 error“No webpage was found for the web address: https://localhost:44374/”
我將具有 2 個類庫和一個 Mvc 項目的項目從 2.2 升級到 MVC Core 3.0,此頁面在此處輸入鏈接描述
更改 .net <TargetFramework>netcoreapp3.0</TargetFramework>
2.像這樣改變
<ItemGroup> <.--<PackageReference Include="Microsoft.AspNetCore.App" />--> <.--<PackageReference Include="Microsoft.AspNetCore.Identity" Version="2.2.0" />--> <PackageReference Include="Microsoft.AspNetCore.Identity.UI" Version="3.0.0" /> <.--<PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.2.0" PrivateAssets="All" />--> <PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="3.0.0" /> </ItemGroup>
3.my satrtup.cs
`
app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseDefaultFiles(); app.UseCookiePolicy();
app.UseRouting(); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapRazorPages(); });`
我的程序.cs
公共 static void Main(string[] args) { CreateHostBuilder(args).Build().Run(); } public static IHostBuilder CreateHostBuilder(string[] args) => Host.CreateDefaultBuilder(args).ConfigureWebHostDefaults(webBuilder => { webBuilder.UseStartup(); });
但是當我運行我的項目時得到這個錯誤
找不到此本地主機頁面沒有找到 web 地址的網頁: https://localhost:44374/ HTTP 錯誤 404
在Startup.cs
試試這個
public void ConfigureServices(IServiceCollection services)
{
//Code above . . .
services.AddMvc( options =>
{
options.EnableEndpointRouting = false;
});
//Code below. . .
}
然后在
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
//Code above . . .
app.UseMvcWithDefaultRoute();
//Code below. . .
}
並刪除
app.UseEndpoints(endpoints =>
{
endpoints.MapRazorPages();
});`
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.