【发布时间】:2020-03-07 03:05:54
【问题描述】:
我有一个简单的Asp Net Web Api,有一个端点,它运行良好。但我想,当您在我的情况下调用根服务器(loclahost:8001/) 时,它会向我返回404,而不是HTTP Error 403.14 - Forbidden。我是ASP NET MVC 的新手,习惯了asp net core。请问,我怎样才能在这里返回404?
也许路由配置会有所帮助:
public class RouteConfig
{
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
name: "Default",
url: "{controller}/{id}",
defaults: new { controller = "GPayController"}
);
}
}
【问题讨论】:
标签: c# asp.net asp.net-web-api error-handling