developer tip

web.config에서 maxJsonLength에 무제한 길이를 설정할 수 있습니까?

optionbox 2020. 10. 2. 22:04
반응형

web.config에서 maxJsonLength에 무제한 길이를 설정할 수 있습니까?


jQuery의 자동 완성 기능을 사용하고 있습니다. 17000 개 이상의 레코드 목록을 검색하려고하면 (각각의 길이가 10자를 넘지 않음) 길이를 초과하고 오류가 발생합니다.

예외 정보 :
예외 유형 : InvalidOperationException
예외 메시지 : JSON JavaScriptSerializer를 사용하여 직렬화 또는 역 직렬화하는 동안 오류가 발생했습니다. 문자열 길이가 maxJsonLength 속성에 설정된 값을 초과합니다.

maxJsonLengthin에 대해 무제한 길이를 설정할 수 있습니까 web.config? 그렇지 않은 경우 설정할 수있는 최대 길이는 얼마입니까?


참고 : 이 답변은 웹 서비스에만 적용됩니다. Controller 메서드에서 JSON을 반환하는 경우 아래 SO 답변도 읽어야합니다. https://stackoverflow.com/a/7207539/1246870


MaxJsonLength의 속성이 제한 될 수 없다, 정수 속성입니다 기본값 102,400 (100,000).

web.config에서 MaxJsonLength 속성을 설정할 수 있습니다.

<configuration> 
   <system.web.extensions>
       <scripting>
           <webServices>
               <jsonSerialization maxJsonLength="50000000"/>
           </webServices>
       </scripting>
   </system.web.extensions>
</configuration> 

MVC 4를 사용 하는 경우이 답변확인하십시오 .


여전히 오류가 발생하는 경우 :

  • maxJsonLengthweb.config에서 속성을 최대 값으로 설정 한 후
  • 데이터 길이가이 값보다 작다는 것을 알고 있습니다.
  • JavaScript 직렬화에 웹 서비스 방법을 사용하지 않습니다.

귀하의 문제는 다음과 같습니다.

MaxJsonLength 속성의 값은 웹 서비스 메서드를 호출하기 위해 비동기 통신 계층에서 사용하는 내부 JavaScriptSerializer 인스턴스에만 적용됩니다. ( MSDN : ScriptingJsonSerializationSection.MaxJsonLength 속성 )

기본적으로 "내부" 는 웹 메소드에서 호출 될 때 JavaScriptSerializer의 값을 존중합니다 maxJsonLength. 직접 사용 JavaScriptSerializer(또는 MVC 작업 방법 / 컨트롤러를 통한 사용)은 적어도 web.config 섹션 에서 속성을 존중 하지 않습니다 .maxJsonLengthsystemWebExtensions.scripting.webServices.jsonSerialization

해결 방법으로 컨트롤러 내에서 (또는 실제로) 다음을 수행 할 수 있습니다.

var serializer = new JavaScriptSerializer();

// For simplicity just use Int32's max value.
// You could always read the value from the config section mentioned above.
serializer.MaxJsonLength = Int32.MaxValue;

var resultData = new { Value = "foo", Text = "var" };
var result = new ContentResult{
    Content = serializer.Serialize(resultData),
    ContentType = "application/json"
};
return result;

이 답변은 이 asp.net 포럼 답변에 대한 나의 해석입니다 .


MVC 4에서는 다음을 수행 할 수 있습니다.

protected override JsonResult Json(object data, string contentType, System.Text.Encoding contentEncoding, JsonRequestBehavior behavior)
{
    return new JsonResult()
    {
        Data = data,
        ContentType = contentType,
        ContentEncoding = contentEncoding,
        JsonRequestBehavior = behavior,
        MaxJsonLength = Int32.MaxValue
    };
}

컨트롤러에서.

부가:

지정해야하는 매개 변수에 의아해하는 사람을 위해 호출은 다음과 같을 수 있습니다.

Json(
    new {
        field1 = true,
        field2 = "value"
        },
    "application/json",
    Encoding.UTF8,
    JsonRequestBehavior.AllowGet
);

web.config 파일에서 json 요청의 최대 길이를 구성 할 수 있습니다.

<configuration>
    <system.web.extensions>
        <scripting>
            <webServices>
                <jsonSerialization maxJsonLength="....">
                </jsonSerialization>
            </webServices>
        </scripting>
    </system.web.extensions>
</configuration>

maxJsonLength의 기본값은 102400 입니다. 자세한 내용은 다음 MSDN 페이지를 참조하십시오. http://msdn.microsoft.com/en-us/library/bb763183.aspx


ASP.NET Web Forms에서이 문제가 발생했습니다. web.config 파일 설정을 완전히 무시했기 때문에 이렇게했습니다.

        JavaScriptSerializer serializer = new JavaScriptSerializer();

        serializer.MaxJsonLength = Int32.MaxValue; 

        return serializer.Serialize(response);

물론 전반적으로 이것은 끔찍한 연습입니다. 웹 서비스 호출에서이 정도의 데이터를 보내는 경우 다른 접근 방식을 찾아야합니다.


다음과 같은 web.config 설정 후에도 여전히 오류가 발생하는 경우 :

<configuration> 
   <system.web.extensions>
       <scripting>
           <webServices>
               <jsonSerialization maxJsonLength="50000000"/>
           </webServices>
       </scripting>
   </system.web.extensions>
</configuration> 

다음과 같이 해결했습니다.

   public ActionResult/JsonResult getData()
   {
      var jsonResult = Json(superlargedata, JsonRequestBehavior.AllowGet);
      jsonResult.MaxJsonLength = int.MaxValue;
      return jsonResult;
    }

이것이 도움이되기를 바랍니다.


나는 그것을 고쳤다.

//your Json data here
string json_object="........";
JavaScriptSerializer jsJson = new JavaScriptSerializer();
jsJson.MaxJsonLength = 2147483644;
MyClass obj = jsJson.Deserialize<MyClass>(json_object);

아주 잘 작동합니다.


나는 vestigal의 대답을 따랐고이 해결책을 얻었습니다.

컨트롤러의 작업에 큰 json을 게시해야 할 때 "JSON JavaScriptSerializer를 사용하여 역 직렬화하는 동안 오류가 발생했습니다. 문자열 길이가 maxJsonLength 속성에 설정된 값을 초과합니다. \ r \ n 매개 변수 이름 : 입력 가치 공급자 ".

내가 한 일은 새 ValueProviderFactory, LargeJsonValueProviderFactory를 만들고 GetDeserializedObject 메서드에서 MaxJsonLength = Int32.MaxValue를 설정하는 것입니다.

public sealed class LargeJsonValueProviderFactory : ValueProviderFactory
{
private static void AddToBackingStore(LargeJsonValueProviderFactory.EntryLimitedDictionary backingStore, string prefix, object value)
{
    IDictionary<string, object> dictionary = value as IDictionary<string, object>;
    if (dictionary != null)
    {
        foreach (KeyValuePair<string, object> keyValuePair in (IEnumerable<KeyValuePair<string, object>>) dictionary)
            LargeJsonValueProviderFactory.AddToBackingStore(backingStore, LargeJsonValueProviderFactory.MakePropertyKey(prefix, keyValuePair.Key), keyValuePair.Value);
    }
    else
    {
        IList list = value as IList;
        if (list != null)
        {
            for (int index = 0; index < list.Count; ++index)
                LargeJsonValueProviderFactory.AddToBackingStore(backingStore, LargeJsonValueProviderFactory.MakeArrayKey(prefix, index), list[index]);
        }
        else
            backingStore.Add(prefix, value);
    }
}

private static object GetDeserializedObject(ControllerContext controllerContext)
{
    if (!controllerContext.HttpContext.Request.ContentType.StartsWith("application/json", StringComparison.OrdinalIgnoreCase))
        return (object) null;
    string end = new StreamReader(controllerContext.HttpContext.Request.InputStream).ReadToEnd();
    if (string.IsNullOrEmpty(end))
        return (object) null;

    var serializer = new JavaScriptSerializer {MaxJsonLength = Int32.MaxValue};

    return serializer.DeserializeObject(end);
}

/// <summary>Returns a JSON value-provider object for the specified controller context.</summary>
/// <returns>A JSON value-provider object for the specified controller context.</returns>
/// <param name="controllerContext">The controller context.</param>
public override IValueProvider GetValueProvider(ControllerContext controllerContext)
{
    if (controllerContext == null)
        throw new ArgumentNullException("controllerContext");
    object deserializedObject = LargeJsonValueProviderFactory.GetDeserializedObject(controllerContext);
    if (deserializedObject == null)
        return (IValueProvider) null;
    Dictionary<string, object> dictionary = new Dictionary<string, object>((IEqualityComparer<string>) StringComparer.OrdinalIgnoreCase);
    LargeJsonValueProviderFactory.AddToBackingStore(new LargeJsonValueProviderFactory.EntryLimitedDictionary((IDictionary<string, object>) dictionary), string.Empty, deserializedObject);
    return (IValueProvider) new DictionaryValueProvider<object>((IDictionary<string, object>) dictionary, CultureInfo.CurrentCulture);
}

private static string MakeArrayKey(string prefix, int index)
{
    return prefix + "[" + index.ToString((IFormatProvider) CultureInfo.InvariantCulture) + "]";
}

private static string MakePropertyKey(string prefix, string propertyName)
{
    if (!string.IsNullOrEmpty(prefix))
        return prefix + "." + propertyName;
    return propertyName;
}

private class EntryLimitedDictionary
{
    private static int _maximumDepth = LargeJsonValueProviderFactory.EntryLimitedDictionary.GetMaximumDepth();
    private readonly IDictionary<string, object> _innerDictionary;
    private int _itemCount;

    public EntryLimitedDictionary(IDictionary<string, object> innerDictionary)
    {
        this._innerDictionary = innerDictionary;
    }

    public void Add(string key, object value)
    {
        if (++this._itemCount > LargeJsonValueProviderFactory.EntryLimitedDictionary._maximumDepth)
            throw new InvalidOperationException("JsonValueProviderFactory_RequestTooLarge");
        this._innerDictionary.Add(key, value);
    }

    private static int GetMaximumDepth()
    {
        NameValueCollection appSettings = ConfigurationManager.AppSettings;
        if (appSettings != null)
        {
            string[] values = appSettings.GetValues("aspnet:MaxJsonDeserializerMembers");
            int result;
            if (values != null && values.Length > 0 && int.TryParse(values[0], out result))
                return result;
        }
        return 1000;
    }
}

}

그런 다음 Global.asax.cs의 Application_Start 메서드에서 ValueProviderFactory를 새 것으로 바꿉니다.

protected void Application_Start()
{
    ...

    //Add LargeJsonValueProviderFactory
    ValueProviderFactory jsonFactory = null;
    foreach (var factory in ValueProviderFactories.Factories)
    {
        if (factory.GetType().FullName == "System.Web.Mvc.JsonValueProviderFactory")
        {
            jsonFactory = factory;
            break;
        }
    }

    if (jsonFactory != null)
    {
        ValueProviderFactories.Factories.Remove(jsonFactory);
    }

    var largeJsonValueProviderFactory = new LargeJsonValueProviderFactory();
    ValueProviderFactories.Factories.Add(largeJsonValueProviderFactory);
}

위의 추가 사항을 web.config에 구현 한 후 "인식 할 수없는 구성 섹션 system.web.extensions"가 표시되는 경우 오류가 발생한 다음 <ConfigSections>섹션 의 web.config에 추가 하십시오.

            <sectionGroup name="system.web.extensions" type="System.Web.Extensions">
              <sectionGroup name="scripting" type="System.Web.Extensions">
                    <sectionGroup name="webServices" type="System.Web.Extensions">
                          <section name="jsonSerialization" type="System.Web.Extensions"/>
                    </sectionGroup>
              </sectionGroup>
        </sectionGroup>

이 줄을 Controller에 쓸 수 있습니다.

json.MaxJsonLength = 2147483644;

이 줄을 web.config

<configuration>
  <system.web.extensions>
    <scripting>
        <webServices>
            <jsonSerialization maxJsonLength="2147483647">
            </jsonSerialization>
        </webServices>
    </scripting>
  </system.web.extensions>

`

안전한 편이 되려면 둘 다 사용하십시오.


MVC MiniProfiler 에서이 오류가 발생 하면 속성 MiniProfiler.Settings.MaxJsonResponseSize을 원하는 값 으로 설정하여 값을 늘릴 수 있습니다 . 기본적으로이 도구는 config에 설정된 값을 무시하는 것 같습니다.

MiniProfiler.Settings.MaxJsonResponseSize = 104857600;

의례 mvc-mini-profiler .


MVC의 Action 메서드에서 MaxJsonLength 속성을 설정하기 만하면됩니다.

JsonResult json= Json(classObject, JsonRequestBehavior.AllowGet);
json.MaxJsonLength = int.MaxValue;
return json;

속성 마법은 어떻습니까?

[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, Inherited = true, AllowMultiple = false)]
public class MaxJsonSizeAttribute : ActionFilterAttribute
{
    // Default: 10 MB worth of one byte chars
    private int maxLength = 10 * 1024 * 1024;

    public int MaxLength
    {
        set
        {
            if (value < 0) throw new ArgumentOutOfRangeException("value", "Value must be at least 0.");

            maxLength = value;
        }
        get { return maxLength; }
    }

    public override void OnActionExecuted(ActionExecutedContext filterContext)
    {
        JsonResult json = filterContext.Result as JsonResult;
        if (json != null)
        {
            if (maxLength == 0)
            {
                json.MaxJsonLength = int.MaxValue;
            }
            else
            {
                json.MaxJsonLength = maxLength;
            }
        }
    }
}

그런 다음 전역 필터 구성 또는 컨트롤러 / 액션 방식을 사용하여 전역 적으로 적용 할 수 있습니다.


Int32.MaxValue로 설정하는 것이 좋습니다.

JavaScriptSerializer serializer = new JavaScriptSerializer();
serializer.MaxJsonLength = Int32.MaxValue;

문제는 정말로 17k 레코드를 반환해야하는지 여부입니다. 브라우저의 모든 데이터를 어떻게 처리 할 계획입니까? 사용자는 어쨌든 17000 행을 스크롤하지 않을 것입니다.

더 나은 방법은 "상위 몇 개"레코드 만 검색하고 필요에 따라 더 많이로드하는 것입니다.


다른 사람들이 말했듯이 구성에서 설정하거나 다음과 같이 직렬 변환기의 개별 인스턴스에 설정할 수 있습니다.

var js = new JavaScriptSerializer() { MaxJsonLength = int.MaxValue };

모델 바인더에 대해 자동으로 역 직렬화되고 너무 큰 JSON을 사용하는 MVC3에서 문제가있는 사용자를 위해 여기에 해결책이 있습니다.

  1. MVC3 소스 코드에서 JsonValueProviderFactory 클래스의 코드를 새 클래스로 복사하십시오.
  2. 개체가 역 직렬화되기 전에 최대 JSON 길이를 변경하는 줄을 추가합니다.
  3. JsonValueProviderFactory 클래스를 새로 수정 된 클래스로 바꿉니다.

이를 수행하는 방법에 대한 올바른 방향 알려준 http://blog.naver.com/techshare/100145191355https://gist.github.com/DalSoft/1588818 에게 감사드립니다 . 첫 번째 사이트의 마지막 링크에는 솔루션에 대한 전체 소스 코드가 포함되어 있습니다.


"무제한"값이없는 것 같습니다. 기본값은 2097152 자이며 유니 코드 문자열 데이터 4MB에 해당합니다.

이미 관찰 된 바와 같이 17,000 개의 레코드는 브라우저에서 잘 사용하기 어렵습니다. 집계보기를 제공하는 경우 서버에서 집계를 수행하고 브라우저에서 요약 만 전송하는 것이 훨씬 더 효율적일 수 있습니다. 예를 들어 파일 시스템 브라우저를 고려하면 트리의 맨 위만보고 드릴 다운 할 때 추가 요청을 내 보냅니다. 각 요청에서 반환되는 레코드 수는 비교적 적습니다. 트리보기 프레젠테이션은 큰 결과 집합에 적합합니다.


방금 만났어요. 6,000 개가 넘는 레코드를 받고 있습니다. 그냥 페이징을하기로 결정했습니다. 에서와 같이 MVC JsonResult 끝점에서 페이지 번호를 수락합니다. 기본값은 0이므로 다음과 같이 필요하지 않습니다.

public JsonResult MyObjects(int pageNumber = 0)

그런 다음 말하는 대신 :

return Json(_repository.MyObjects.ToList(), JsonRequestBehavior.AllowGet);

내가 말하다:

return Json(_repository.MyObjects.OrderBy(obj => obj.ID).Skip(1000 * pageNumber).Take(1000).ToList(), JsonRequestBehavior.AllowGet);

아주 간단합니다. 그런 다음 JavaScript에서이 대신 :

function myAJAXCallback(items) {
    // Do stuff here
}

나는 대신 말한다 :

var pageNumber = 0;
function myAJAXCallback(items) {
    if(items.length == 1000)
        // Call same endpoint but add this to the end: '?pageNumber=' + ++pageNumber
    }
    // Do stuff here
}

그리고 처음에 그들과 함께하던 일에 기록을 추가하십시오. 또는 모든 통화가 끝날 때까지 기다렸다가 결과를 함께 조정하십시오.


이 코드를 추가하여 문제를 해결했습니다.

String confString = HttpContext.Current.Request.ApplicationPath.ToString();
Configuration conf = WebConfigurationManager.OpenWebConfiguration(confString);
ScriptingJsonSerializationSection section = (ScriptingJsonSerializationSection)conf.GetSection("system.web.extensions/scripting/webServices/jsonSerialization");
section.MaxJsonLength = 6553600;
conf.Save();

View에서 이러한 종류의 문제가 발생하면 아래 방법을 사용하여 해결할 수 있습니다. 여기에서는 Newtonsoft 패키지를 사용했습니다.

@using Newtonsoft.Json
<script type="text/javascript">
    var partData = @Html.Raw(JsonConvert.SerializeObject(ViewBag.Part));
</script>

대체 ASP.NET MVC 5 수정 :

(내는 약간의 작은 변경 사항을 제외하고 위의 MFC 답변과 유사합니다)

아직 Json.NET으로 변경할 준비가되지 않았으며 제 경우에는 요청 중에 오류가 발생했습니다. 내 시나리오에서 가장 좋은 방법 JsonValueProviderFactory은 글로벌 프로젝트에 수정 사항을 적용 하는 실제 수정하는 것이었고 global.cs파일을 편집하여 수행 할 수 있습니다 .

JsonValueProviderConfig.Config(ValueProviderFactories.Factories);

web.config 항목을 추가하십시오.

<add key="aspnet:MaxJsonLength" value="20971520" />

다음 두 개의 클래스를 만듭니다.

public class JsonValueProviderConfig
{
    public static void Config(ValueProviderFactoryCollection factories)
    {
        var jsonProviderFactory = factories.OfType<JsonValueProviderFactory>().Single();
        factories.Remove(jsonProviderFactory);
        factories.Add(new CustomJsonValueProviderFactory());
    }
}

이것은 기본적으로에서 찾은 기본 구현의 정확한 사본 System.Web.Mvc이지만 구성 가능한 web.config appsetting 값이 추가 aspnet:MaxJsonLength됩니다.

public class CustomJsonValueProviderFactory : ValueProviderFactory
{

    /// <summary>Returns a JSON value-provider object for the specified controller context.</summary>
    /// <returns>A JSON value-provider object for the specified controller context.</returns>
    /// <param name="controllerContext">The controller context.</param>
    public override IValueProvider GetValueProvider(ControllerContext controllerContext)
    {
        if (controllerContext == null)
            throw new ArgumentNullException("controllerContext");

        object deserializedObject = CustomJsonValueProviderFactory.GetDeserializedObject(controllerContext);
        if (deserializedObject == null)
            return null;

        Dictionary<string, object> strs = new Dictionary<string, object>(StringComparer.OrdinalIgnoreCase);
        CustomJsonValueProviderFactory.AddToBackingStore(new CustomJsonValueProviderFactory.EntryLimitedDictionary(strs), string.Empty, deserializedObject);

        return new DictionaryValueProvider<object>(strs, CultureInfo.CurrentCulture);
    }

    private static object GetDeserializedObject(ControllerContext controllerContext)
    {
        if (!controllerContext.HttpContext.Request.ContentType.StartsWith("application/json", StringComparison.OrdinalIgnoreCase))
            return null;

        string fullStreamString = (new StreamReader(controllerContext.HttpContext.Request.InputStream)).ReadToEnd();
        if (string.IsNullOrEmpty(fullStreamString))
            return null;

        var serializer = new JavaScriptSerializer()
        {
            MaxJsonLength = CustomJsonValueProviderFactory.GetMaxJsonLength()
        };
        return serializer.DeserializeObject(fullStreamString);
    }

    private static void AddToBackingStore(EntryLimitedDictionary backingStore, string prefix, object value)
    {
        IDictionary<string, object> strs = value as IDictionary<string, object>;
        if (strs != null)
        {
            foreach (KeyValuePair<string, object> keyValuePair in strs)
                CustomJsonValueProviderFactory.AddToBackingStore(backingStore, CustomJsonValueProviderFactory.MakePropertyKey(prefix, keyValuePair.Key), keyValuePair.Value);

            return;
        }

        IList lists = value as IList;
        if (lists == null)
        {
            backingStore.Add(prefix, value);
            return;
        }

        for (int i = 0; i < lists.Count; i++)
        {
            CustomJsonValueProviderFactory.AddToBackingStore(backingStore, CustomJsonValueProviderFactory.MakeArrayKey(prefix, i), lists[i]);
        }
    }

    private class EntryLimitedDictionary
    {
        private static int _maximumDepth;

        private readonly IDictionary<string, object> _innerDictionary;

        private int _itemCount;

        static EntryLimitedDictionary()
        {
            _maximumDepth = CustomJsonValueProviderFactory.GetMaximumDepth();
        }

        public EntryLimitedDictionary(IDictionary<string, object> innerDictionary)
        {
            this._innerDictionary = innerDictionary;
        }

        public void Add(string key, object value)
        {
            int num = this._itemCount + 1;
            this._itemCount = num;
            if (num > _maximumDepth)
            {
                throw new InvalidOperationException("The length of the string exceeds the value set on the maxJsonLength property.");
            }
            this._innerDictionary.Add(key, value);
        }
    }

    private static string MakeArrayKey(string prefix, int index)
    {
        return string.Concat(prefix, "[", index.ToString(CultureInfo.InvariantCulture), "]");
    }

    private static string MakePropertyKey(string prefix, string propertyName)
    {
        if (string.IsNullOrEmpty(prefix))
        {
            return propertyName;
        }
        return string.Concat(prefix, ".", propertyName);
    }

    private static int GetMaximumDepth()
    {
        int num;
        NameValueCollection appSettings = ConfigurationManager.AppSettings;
        if (appSettings != null)
        {
            string[] values = appSettings.GetValues("aspnet:MaxJsonDeserializerMembers");
            if (values != null && values.Length != 0 && int.TryParse(values[0], out num))
            {
                return num;
            }
        }
        return 1000;
    }

    private static int GetMaxJsonLength()
    {
        int num;
        NameValueCollection appSettings = ConfigurationManager.AppSettings;
        if (appSettings != null)
        {
            string[] values = appSettings.GetValues("aspnet:MaxJsonLength");
            if (values != null && values.Length != 0 && int.TryParse(values[0], out num))
            {
                return num;
            }
        }
        return 1000;
    }
}

 JsonResult result = Json(r);
 result.MaxJsonLength = Int32.MaxValue;
 result.JsonRequestBehavior = JsonRequestBehavior.AllowGet;
 return result;

사용하다 lib\Newtonsoft.Json.dll

public string serializeObj(dynamic json) {        
    return JsonConvert.SerializeObject(json);
}

WebForms UpdatePanel 솔루션 :

Web.config에 설정을 추가합니다.

<configuration>
  <appSettings>
    <add key="aspnet:UpdatePanelMaxScriptLength" value="2147483647" />
  </appSettings>
</configuration>

https://support.microsoft.com/en-us/kb/981884

ScriptRegistrationManager 클래스에는 다음 코드가 포함되어 있습니다.

// Serialize the attributes to JSON and write them out
JavaScriptSerializer serializer = new JavaScriptSerializer();

// Dev10# 877767 - Allow configurable UpdatePanel script block length
// The default is JavaScriptSerializer.DefaultMaxJsonLength
if (AppSettings.UpdatePanelMaxScriptLength > 0) {
    serializer.MaxJsonLength = AppSettings.UpdatePanelMaxScriptLength;
}  

string attrText = serializer.Serialize(attrs);

서버 측 변경이 필요하지 않습니다. 이 문제는 web.config 파일로만 수정할 수 있습니다 . 이것을 시도

<appSettings>
 <add key="aspnet:MaxJsonDeserializerMembers" value="2147483647" />
<add key="aspnet:UpdatePanelMaxScriptLength" value="2147483647" />
</appSettings>  

and   

<system.web.extensions>
<scripting>
  <webServices>
    <jsonSerialization maxJsonLength="2147483647"/>
  </webServices>
</scripting>


이 maxJsonLength 값이 int이면 int 32bit / 64bit / 16bit가 얼마나 큰지 .... 나는 내 maxJsonLength로 설정할 수있는 최대 값이 얼마인지 확인하고 싶습니다.

<scripting>
        <webServices>
            <jsonSerialization maxJsonLength="2147483647">
            </jsonSerialization>
        </webServices>
    </scripting>

web.config로 할 필요가 없습니다. 통과 목록의 값을 포착하는 동안 짧은 속성을 사용할 수 있습니다. 예를 들어 다음과 같은 모델을 선언합니다.

public class BookModel
    {
        public decimal id { get; set; }  // 1 

        public string BN { get; set; } // 2 Book Name

        public string BC { get; set; } // 3 Bar Code Number

        public string BE { get; set; } // 4 Edition Name

        public string BAL { get; set; } // 5 Academic Level

        public string BCAT { get; set; } // 6 Category
}

여기에서는 BC = 바코드 BE = 책 판 등과 같은 짧은 비율을 사용합니다.

참고 URL : https://stackoverflow.com/questions/1151987/can-i-set-an-unlimited-length-for-maxjsonlength-in-web-config

반응형