ASP.NET Web方法,以XML作为参数 [英] ASP.NET Web Method, XML as an argument

查看:117
本文介绍了ASP.NET Web方法,以XML作为参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我有一个带有字符串参数的web方法.
当我从asp.net页调用此webmethod时,该参数是合法的XML字符串.

该webmethod接受参数,并使用它对表执行批量插入. (它使用COM调用SQL存储过程.该存储过程工作正常.我的XML输入也是合法的.)

问题是,输入的XML字符串可能最大为5MB或更大.

运行代码时,我只会收到HTTP 500错误.我在这里被打中.

有人可以告诉我,如何使用一个大XML字符串作为参数来调用Web方法吗?

谢谢和问候,
Renuka Prasad.

Hi,

I have a webmethod which has a string argument.
When I invoke this webmethod from an asp.net page, the argument is a legal XML string.

The webmethod takes in the argument and uses it to perform bulk-insert into a table. (it calls an SQL stored procedure using COM. The stored procedure works fine. My XML input is also legal.)

The problem is, the input XML string can be as large as 5MB or more.

When I run the code, I simply get a HTTP 500 error. I am struck here.

Can some one please tell me, how I can invoke a web method with one of the arguments being a large XML string?

Thanks and Regards,
Renuka Prasad.

推荐答案

看起来您需要在web/machine.config文件中定义如下内容:

Looks like you need to define something like this in your web/machine.config files:

<httpRuntime 

    maxRequestLength="1048576"

    executionTimeout="3600"/>


httpRuntime maxRequestLength:
此属性用于通过拒绝超出一定限制的任何数据来限制数据传输的大小.该限制是指HTTP上传的总大小(以KB为单位)(大约等于要上传的所有文件的总和).默认情况下,这是4096 KB.您应该在此处设置一个合理的限制,以阻止恶意访问者通过上传过大的文件来占用您的带宽.
如果上载的大小太大,服务器将拒绝接受.由于服务器拒绝了该请求,因此上载的浏览器将报告该提交页面不可用.
有关此标签的更多详细信息,请参见:
HttpRuntime [


httpRuntime maxRequestLength:
This attribute is used to limit the size of the data transfer by rejecting any which exceed a certain limit. The limit refers to the total size of the HTTP upload in KB (approximately equal to the sum of all the files being upload). By default this is 4096 KB. You should set a sensible limit here to stop malicious visitors using up your bandwidth by uploading excessively large files.
If the size of an upload is too great the server will refuse to accept it. Because the server is refusing the request the uploading browser will report that the submission page is not available.
For further detail about this tag, refer:
HttpRuntime[^]


In case, this does not resolve your issue please check/post the error reported in the EventViewer(Run -> Eventvwr) of the server system.


这篇关于ASP.NET Web方法,以XML作为参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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