asp.net core 如何全局设置404错误

Service.AddControllers()
            .ConfigureApiBehaviorOptions(options =>
            {
                options.SuppressConsumesConstraintForFormFileParameters = true;
                options.SuppressInferBindingSourcesForParameters = true;
                options.SuppressModelStateInvalidFilter = true;
                options.SuppressMapClientErrors = true;
                options.ClientErrorMapping[404].Link =
                    "https://*/404";
            });

如上述代码,在控制器中添加404导航即可

你可能感兴趣的:(c#,asp.net,mvc,asp.net,core,大数据,asp.net,core)