如何POST数据到ASP

如何POST数据到ASP

本文介绍了如何POST数据到ASP.NET的HttpHandler?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想通过一个HTTP处理程序发送数据的一大块。因为URL长度的限制,我不能使用GET发送,所以我决定将它张贴代替。问题是,我不能得到的值。 context.Request.Form表明,它有0项。那么,有没有办法,我可以POST数据到一个HttpHandler的?

I am trying to send a large chunk of data over to a HTTP handler. I can't send it using GET because of the URL length limit so I decided to POST it instead. The problem is that I can't get at the values. context.Request.Form shows that it has 0 items. So is there a way that I can POST data to a HttpHandler?

推荐答案

有一些code看将有助于诊断问题。您是否尝试过这样的事情?

Having some code to look at would help diagnose the issue. Have you tried something like this?

jQuery的code:

jQuery code:

$.post('test.ashx',
       {key1: 'value1', key2: 'value2'},
       function(){alert('Complete!');});

然后在你的的ProcessRequest()方法,你应该能够做到:

Then in your ProcessRequest() method, you should be able to do:

string key1 = context.Request.Form["key1"];

您也可以检查请求的类型中的ProcessRequest()方法来调试问题。

You can also check the request type in the ProcessRequest() method to debug the issue.

if(context.Request.RequestType == "POST")
{
    // Request should have been sent successfully
}
else
{
    // Request was sent incorrectly somehow
}

这篇关于如何POST数据到ASP.NET的HttpHandler?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 21:34