简体   繁体   English

黑页或404 Asp.NET Core中的每个请求

[英]Black page or 404 every request in Asp.NET core

my Asp.NET Core project returns 404 with Postman or a blank page with a browser after every request. 我的Asp.NET Core项目在每次请求后都返回404(带有Postman)或空白页(带有浏览器)。 I'm using Asp.NET Core 1.1.2. 我正在使用Asp.NET Core 1.1.2。 I already tried to: 我已经尝试过:

  • clean the solution 清洁溶液
  • delete the .vs folder 删除.vs文件夹
  • restore Visual Studio 还原Visual Studio
  • create a new project and copy every file (empty project works) 创建一个新项目并复制每个文件(空项目有效)

Startup.cs, appsettings.json, web.config have not been edited. Startup.cs,appsettings.json,web.config尚未被编辑。

I have SSL enabled and HTTPS rewrite. 我已启用SSL和重写HTTPS。

This happenes on both IIS Express and the project directly. IIS Express和项目都直接发生这种情况。

Routing: 路由:

app.UseMvc(routes => {
    routes.MapRoute(
        name: "default",
        template: "{controller=Home}/{action=Index}/{id?}");
});

Log: 日志:

  • Microsoft.AspNetCore.Routing.RouteBase:Debug: Request successfully matched the route with name 'default' and template '{controller=Home}/{action=Index}/{id?}'. Microsoft.AspNetCore.Routing.RouteBase:Debug:请求已成功匹配名称为“ default”且模板为“ {controller = Home} / {action = Index} / {id?}”的路由。
  • Microsoft.AspNetCore.Mvc.Internal.MvcRouteHandler:Debug: No actions matched the current request Microsoft.AspNetCore.Mvc.Internal.MvcRouteHandler:Debug:没有与当前请求匹配的操作
  • Microsoft.AspNetCore.Builder.RouterMiddleware:Debug: Request did not match any routes. Microsoft.AspNetCore.Builder.RouterMiddleware:Debug:请求与任何路由都不匹配。

铬

邮差

So, the problem was Microsoft.AspNetCore.Mvc.Versioning. 因此,问题出在Microsoft.AspNetCore.Mvc.Versioning。 With version 1.1.x you need to add "app.UseApiVersioning()" in the configure method after app.UseMvc(...); 对于版本1.1.x,需要在app.UseMvc(...)之后的configure方法中添加“ app.UseApiVersioning()”。

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

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