修复错误
This commit is contained in:
@@ -17,25 +17,26 @@ using System.Web.Http.Filters;
|
||||
namespace NX.ERP.WebAPi
|
||||
{
|
||||
|
||||
public class JsonContentNegotiator : IContentNegotiator
|
||||
{
|
||||
private readonly JsonMediaTypeFormatter _jsonFormatter;
|
||||
//public class JsonContentNegotiator : IContentNegotiator
|
||||
//{
|
||||
// private readonly JsonMediaTypeFormatter _jsonFormatter;
|
||||
|
||||
public JsonContentNegotiator(JsonMediaTypeFormatter formatter)
|
||||
{
|
||||
_jsonFormatter = formatter;
|
||||
}
|
||||
// public JsonContentNegotiator(JsonMediaTypeFormatter formatter)
|
||||
// {
|
||||
// _jsonFormatter = formatter;
|
||||
// }
|
||||
|
||||
public ContentNegotiationResult Negotiate(Type type, HttpRequestMessage request, IEnumerable<MediaTypeFormatter> formatters)
|
||||
{
|
||||
var result = new ContentNegotiationResult(_jsonFormatter, new MediaTypeHeaderValue("application/json"));
|
||||
return result;
|
||||
}
|
||||
}
|
||||
// public ContentNegotiationResult Negotiate(Type type, HttpRequestMessage request, IEnumerable<MediaTypeFormatter> formatters)
|
||||
// {
|
||||
// var result = new ContentNegotiationResult(_jsonFormatter, new MediaTypeHeaderValue("application/json"));
|
||||
// return result;
|
||||
// }
|
||||
//}
|
||||
public static class WebApiConfig
|
||||
{
|
||||
public static void Register(HttpConfiguration config)
|
||||
{
|
||||
|
||||
|
||||
NX.ERP.U8.U8LoginContext.Instance.AccID = System.Configuration.ConfigurationManager.AppSettings["AccId"];
|
||||
NX.ERP.U8.U8LoginContext.Instance.PassWord = System.Configuration.ConfigurationManager.AppSettings["Password"];
|
||||
@@ -43,12 +44,12 @@ namespace NX.ERP.WebAPi
|
||||
NX.ERP.U8.U8LoginContext.Instance.UserId = System.Configuration.ConfigurationManager.AppSettings["UserId"];
|
||||
NX.ERP.U8.U8LoginContext.Instance.Server= System.Configuration.ConfigurationManager.AppSettings["Server"];
|
||||
|
||||
|
||||
//System.Web.Http.Filters.IExceptionFilter
|
||||
config.Filters.Add(new ExceptionFilter());
|
||||
config.Filters.Add(new ApiResultAttribute());
|
||||
Console.WriteLine(config.Filters.Count);
|
||||
// Web API 配置和服务
|
||||
GlobalConfiguration.Configuration.Formatters.JsonFormatter.SerializerSettings = new JsonSerializerSettings
|
||||
config.Formatters.JsonFormatter.SerializerSettings = new JsonSerializerSettings
|
||||
{
|
||||
//忽略循环引用,如果设置为Error,则遇到循环引用的时候报错
|
||||
ReferenceLoopHandling = ReferenceLoopHandling.Ignore,
|
||||
|
||||
Reference in New Issue
Block a user