如何在ASP.NET Web应用程序中从服务器端向客户端发送大字符串 [英] How to send large string from server side to client side in ASP.NET web application

查看:69
本文介绍了如何在ASP.NET Web应用程序中从服务器端向客户端发送大字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从服务器向客户端发送超过300k字符的大字符串。

更少字符它工作正常但是如果我发送大数据它在GetVal的客户端给我错误( )

的ScriptResource.axd d = ZcwVAK_NOhic4vV9c3pDrDgVOGeXTSmbV_h4hrB4AYvCck3CzugURz2Hh_coReQTH7g2Ic1Q-zr149y9DQxensyPFeoHX0_89UV7i63FJ5OMUYEZYqd0AqrTxEX33GzUL3THCXUISUSAdnLW_M1p5h7si3pju0-GYZycWvLFRcYN_zu_LztKZOOtUeyfUR-E0& T公司= 3d0d00d7:6076 POST HTTP://本地主机:60125 /...../ GETVAL 500(内部服务器错误)





请帮我这个



我尝试过:



Java脚本:

 PageMethods.GetVal (x,onRequestComplete,onError); 





服务器端vb:

< System.Web .Services.WebMethod()> _ 
公共共享函数GetVal(ByVal x As String)As String
Dim a As String
//逻辑使用x值从db获取值
返回
结束函数

解决方案

你可能超过最大响应长度:

< blockquote class =quote>

maxJsonLength 指定JSON字符串的最大长度(最大UTF-8字符数) )。默认长度为 102400



更改 web.config 文件中的设置以增加最大值:

 <  配置 < span class =code-keyword>>  
< system.web.extensions >
< 脚本 >
< webServices >
< jsonSerialization maxJsonLength = 500000 / >
< < span class =code-leadattribute> / webServices >
< / scripting >
< / system.web.extensions >
< / configuration >


I am trying to send large string more than 300k characters from server to client side.
for less character its works fine but if i send large data it gives me error at client side at GetVal()

ScriptResource.axd?d=ZcwVAK_NOhic4vV9c3pDrDgVOGeXTSmbV_h4hrB4AYvCck3CzugURz2Hh_coReQTH7g2Ic1Q-zr149y9DQxensyPFeoHX0_89UV7i63FJ5OMUYEZYqd0AqrTxEX33GzUL3THCXUISUSAdnLW_M1p5h7si3pju0-GYZycWvLFRcYN_zu_LztKZOOtUeyfUR-e0&t=3d0d00d7:6076 POST http://localhost:60125/...../GetVal 500 (Internal Server Error)



Please help me for this

What I have tried:

Java script:

PageMethods.GetVal(x, onRequestComplete, onError);



server side vb:

<System.Web.Services.WebMethod()> _
   Public Shared Function GetVal(ByVal x As String) As String
     Dim a As String
    //logic to get a value from db using x value
     Return a
   End Function

解决方案

You're probably exceeding the maximum response length:

maxJsonLength Specifies the maximum length of the JSON string (the maximum number of UTF-8 characters). The default length is 102400.


Change the settings in your web.config file to increase the maximum:

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


这篇关于如何在ASP.NET Web应用程序中从服务器端向客户端发送大字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆