我正面临以下问题。当我运行项目时,会发生执行“ KeyNotFoundException:给定的键在词典中不存在”的情况。
public void ConfigureServices(IServiceCollection services)
{
if (services == null)
{
throw new ArgumentNullException(nameof(services));
}
// Add framework services.
services.AddMvc(options =>
{
options.Filters.Add(new CustomExceptionFilterAttribute());
options.ReturnHttpNotAcceptable = true;
// options.OutputFormatters = xml
})
.AddJsonOptions(options =>
{
//For Maintaining Json Format
options.SerializerSettings.ContractResolver = new Newtonsoft.Json.Serialization.DefaultContractResolver();
});
}
您的帮助将不胜感激。