异步从ASP.NET发出10个POST请求 [英] Making 10 POST requests from ASP.NET asynchronously

查看:52
本文介绍了异步从ASP.NET发出10个POST请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,


是否可以异步从ASP.NET发出10个POST请求?我已经花了几天时间来解决这个问题,而且我似乎还在继续运行

来应对IIS限制。基本上这里是现在正在运行的过程

(同步):


人员访问mywebsite.com并填写表格

mywebsite.com向providerwebsite.com发送一个请求

mywebsite.com收到回复

mywebsite.com向providerwebsite.com发送第二个请求

mywebsite.com收到回复

....

mywebsite.com向providerwebsite.com发送第1​​0个请求

mywebsite.com收到回复


我想要发生的事情(异步):


访问mywebsite.com并填写表格

mywebsite.com向providerwebsite.com发送一个请求

mywebsite.com向providerwebsite.com发送第二个请求

mywebsite.com收到第一个响应请求

....

mywebsite.com向providerwebsite.com发送第十个请求

mywebsite.com收到对第九个请求的响应

mywebsite.c om收到对第十个请求的回复


上面只是一个例子 - 响应应该能够以异步方式到达任何

顺序。问题是,每个请求最多可能需要800个b / b $ b ms才能响应,10次同步请求时间= 8秒......太长了...

这个想法是如果我可以异步发送所有十个请求,结果

应该开始更快地返回。


这是否可以用于ASP.NET和IIS?

Hi all,

Is it possible to make 10 POST requests from ASP.NET asynchronously? I have
been working on this problem for a few days now, and I seem to keep running
up against IIS limitations. Basically here''s the process as it works now
(synchronously):

Person visits mywebsite.com and fills out a form
mywebsite.com POSTs one request to providerwebsite.com
mywebsite.com receives response
mywebsite.com POSTs a second request to providerwebsite.com
mywebsite.com receives response
....
mywebsite.com POSTs a tenth request to providerwebsite.com
mywebsite.com receives response

What I would like to happen is (asynchronously):

Person visits mywebsite.com and fills out a form
mywebsite.com POSTs one request to providerwebsite.com
mywebsite.com POSTs a second request to providerwebsite.com
mywebsite.com receives a response to first request
....
mywebsite.com POSTs a tenth request to providerwebsite.com
mywebsite.com receives a response to ninth request
mywebsite.com receives a response to tenth request

The above is just an example - the responses should be able to arrive in any
order asynchronously. The problem is that each request can take up to 800
ms to respond, times 10 synchronous requests = 8 seconds... way too long...
The idea is that if I can send all ten requests asynchronously, the results
should start being returned much faster.

Is this even possible with ASP.NET and IIS?

推荐答案

你有没有看过线程?

http://msdn2.microsoft.com/en-us/lib...hreadpool.aspx

http:// msdn.microsoft.com/msdnmag/is...10/WickedCode/

-

-

问候


John Timney(MVP)

访问我的网站:
http://www.johntimne y.com
http://www.johntimney.com/blog

" Mike C#" < xy*@xyz.com写在留言中

news:y6 ************* @ newsfe11.lga ...
Have you looked up threading yet?

http://msdn2.microsoft.com/en-us/lib...hreadpool.aspx

http://msdn.microsoft.com/msdnmag/is...10/WickedCode/

--
--
Regards

John Timney (MVP)
VISIT MY WEBSITE:
http://www.johntimney.com
http://www.johntimney.com/blog
"Mike C#" <xy*@xyz.comwrote in message
news:y6*************@newsfe11.lga...

大家好,


是否有可能异步地从ASP.NET发出10个POST请求?我现在已经在这个问题上工作了几天,而且我似乎一直在努力克服IIS的限制。基本上就是这个过程,因为它现在(同步)工作



人访问mywebsite.com并填写表格

mywebsite.com向providerwebsite.com发送一个请求

mywebsite.com收到回复

mywebsite.com向providerwebsite.com发送第二个请求

mywebsite.com收到回复

...

mywebsite.com向providerwebsite.com发送第十个请求

mywebsite.com收到回复


我想要发生的是(异步):


访问mywebsite.com并填写表格

mywebsite.com向providerwebsite.com发送一个请求

mywebsite.com向providerwebsite.com发送第二个请求

mywebsite.com收到对第一个请求的响应

...

mywebsite.com向providerwebsite.com发送第十个请求

mywebsite.com收到对第九个请求的回复

mywebsite.com重新开始放弃对第十个请求的回复


以上只是一个例子 - 响应应该能够异步到达任何订单的

。问题是,每个请求最多需要800美元到800美元才能响应,10个同步请求时间= 8秒......方式太多

长...这个想法是如果我可以异步发送所有十个请求,

结果应该开始更快地返回。


这是否可以使用ASP.NET和IIS?
Hi all,

Is it possible to make 10 POST requests from ASP.NET asynchronously? I
have been working on this problem for a few days now, and I seem to keep
running up against IIS limitations. Basically here''s the process as it
works now (synchronously):

Person visits mywebsite.com and fills out a form
mywebsite.com POSTs one request to providerwebsite.com
mywebsite.com receives response
mywebsite.com POSTs a second request to providerwebsite.com
mywebsite.com receives response
...
mywebsite.com POSTs a tenth request to providerwebsite.com
mywebsite.com receives response

What I would like to happen is (asynchronously):

Person visits mywebsite.com and fills out a form
mywebsite.com POSTs one request to providerwebsite.com
mywebsite.com POSTs a second request to providerwebsite.com
mywebsite.com receives a response to first request
...
mywebsite.com POSTs a tenth request to providerwebsite.com
mywebsite.com receives a response to ninth request
mywebsite.com receives a response to tenth request

The above is just an example - the responses should be able to arrive in
any order asynchronously. The problem is that each request can take up to
800 ms to respond, times 10 synchronous requests = 8 seconds... way too
long... The idea is that if I can send all ten requests asynchronously,
the results should start being returned much faster.

Is this even possible with ASP.NET and IIS?



如果是2.0,你也可以尝试使用WebClient对象的Async方法...


AFAIK如果外部服务器看不到这些请求属于同一会话的

(除非你做一些特别的事情,可能就是这种情况),

它应该工作。我不认为你在自己的服务器上会有这个限制

(因为你的服务器充当外部网站的客户端)。


-

Patrice


" Mike C#" <xy*@xyz.comaécritdansle message de news:

y6 ************* @ newsfe11.lga ...
If 2.0 you could also try the Async methods of the WebClient object...

AFAIK if those requests are not seen by the external server as belonging to
the same session (which is likely the case unless you do something special),
it should work. I don''t think you''ll have this limitation on your own server
(as your server act as a client to the external web site).

--
Patrice

"Mike C#" <xy*@xyz.coma écrit dans le message de news:
y6*************@newsfe11.lga...

大家好,


是否有可能异步地从ASP.NET发出10个POST请求?我现在已经在这个问题上工作了几天,而且我似乎一直在努力克服IIS的限制。基本上就是这个过程,因为它现在(同步)工作



人访问mywebsite.com并填写表格

mywebsite.com向providerwebsite.com发送一个请求

mywebsite.com收到回复

mywebsite.com向providerwebsite.com发送第二个请求

mywebsite.com收到回复

...

mywebsite.com向providerwebsite.com发送第十个请求

mywebsite.com收到回复


我想要发生的是(异步):


访问mywebsite.com并填写表格

mywebsite.com向providerwebsite.com发送一个请求

mywebsite.com向providerwebsite.com发送第二个请求

mywebsite.com收到对第一个请求的响应

...

mywebsite.com向providerwebsite.com发送第十个请求

mywebsite.com收到对第九个请求的回复

mywebsite.com重新开始放弃对第十个请求的回复


以上只是一个例子 - 响应应该能够异步到达任何订单的

。问题是,每个请求最多需要800美元到800美元才能响应,10个同步请求时间= 8秒......方式太多

长...这个想法是如果我可以异步发送所有十个请求,

结果应该开始更快地返回。


这是否可以使用ASP.NET和IIS?
Hi all,

Is it possible to make 10 POST requests from ASP.NET asynchronously? I
have been working on this problem for a few days now, and I seem to keep
running up against IIS limitations. Basically here''s the process as it
works now (synchronously):

Person visits mywebsite.com and fills out a form
mywebsite.com POSTs one request to providerwebsite.com
mywebsite.com receives response
mywebsite.com POSTs a second request to providerwebsite.com
mywebsite.com receives response
...
mywebsite.com POSTs a tenth request to providerwebsite.com
mywebsite.com receives response

What I would like to happen is (asynchronously):

Person visits mywebsite.com and fills out a form
mywebsite.com POSTs one request to providerwebsite.com
mywebsite.com POSTs a second request to providerwebsite.com
mywebsite.com receives a response to first request
...
mywebsite.com POSTs a tenth request to providerwebsite.com
mywebsite.com receives a response to ninth request
mywebsite.com receives a response to tenth request

The above is just an example - the responses should be able to arrive in
any order asynchronously. The problem is that each request can take up to
800 ms to respond, times 10 synchronous requests = 8 seconds... way too
long... The idea is that if I can send all ten requests asynchronously,
the results should start being returned much faster.

Is this even possible with ASP.NET and IIS?



" Mike C#" < xy*@xyz.com写在留言中

news:y6 ************* @ newsfe11.lga ...
"Mike C#" <xy*@xyz.comwrote in message
news:y6*************@newsfe11.lga...

大家好,


是否有可能异步地从ASP.NET发出10个POST请求?我现在已经在这个问题上工作了几天,而且我似乎一直在努力克服IIS的限制。基本上这是'过程,因为它现在(同步)
工作:
Hi all,

Is it possible to make 10 POST requests from ASP.NET asynchronously? I
have been working on this problem for a few days now, and I seem to keep
running up against IIS limitations. Basically here''s the process as it
works now (synchronously):



正如你所说,这是一个IIS限制。它与ASP.NET无关。


唯一的ASP.NET关系是你可能没有调用Dispose on

你的代理对象,所以你没有关闭连接。


John

It is an IIS limit, as you say. It has nothing to do with ASP.NET.

The only ASP.NET relation is that you probably aren''t calling Dispose on
your proxy objects, so you''re not closing the connections.

John


这篇关于异步从ASP.NET发出10个POST请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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