Commit fe2180bd by xiongyuwen

Update Startup.cs

parent 9c81b280
......@@ -34,7 +34,7 @@ namespace Bailun.Discuz
services.AddMicroServiceApi<ITaskJobApi>(ConfigManagerConf.GetValue("ApiServerUrl:TaskJobUrl"));
//扩大接口能接收的post容量
//扩大接口能接收的post容量
services.Configure<FormOptions>(options =>
{
options.ValueCountLimit = int.MaxValue; // 2000 items max
......@@ -54,17 +54,8 @@ namespace Bailun.Discuz
// var factory = p.GetRequiredService<IHttpApiFactory<IProductApi>>();
// return factory.CreateHttpApi();
//});
//添加cors 服务 配置跨域处理
services.AddCors(options =>
{
options.AddPolicy("any", builder =>
{
builder.WithMethods("GET", "POST", "HEAD", "PUT", "DELETE", "OPTIONS")
//.AllowCredentials()//指定处理cookie
.AllowAnyOrigin(); //允许任何来源的主机访问
});
});
//注入日志
//注入日志
services.AddSingleton<ILessLog, LessLog>();
return services.AddAbpService<ServiceModule,BaseContext>(_appConfiguration);
}
......@@ -79,7 +70,7 @@ namespace Bailun.Discuz
}
/// <summary>
/// 默认提交异常处理事件
/// 默认提交异常处理事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
......@@ -91,31 +82,31 @@ namespace Bailun.Discuz
e.Cancel = true;
return;
}
// 只处理未处理的异常
// 只处理未处理的异常
if (!e.IsUnhandledError)
return;
//忽略没有错误体的错误
//忽略没有错误体的错误
var error = argEvent.GetError();
if (error == null)
return;
// 忽略404错误
// 忽略404错误
if (e.Event.IsNotFound())
{
e.Cancel = true;
return;
}
//忽略401(Unauthorized)和请求验证的错误.
//忽略401(Unauthorized)和请求验证的错误.
if (error.Code == "401")
{
e.Cancel = true;
return;
}
//忽略任何未被代码抛出的异常
//忽略任何未被代码抛出的异常
var handledNamespaces = new List<string> { "Exceptionless" };
var handledNamespaceList = error.StackTrace.Select(s => s.DeclaringNamespace).Distinct();
if (!handledNamespaceList.Any(ns => handledNamespaces.Any(ns.Contains)))
......@@ -124,8 +115,8 @@ namespace Bailun.Discuz
return;
}
e.Event.Tags.Add("未捕获异常");//添加系统异常标签
e.Event.MarkAsCritical();//标记为关键异常
e.Event.Tags.Add("未捕获异常");//添加系统异常标签
e.Event.MarkAsCritical();//标记为关键异常
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment