响应 HTTP POST

发布于 2024-09-26 06:12:43 字数 570 浏览 2 评论 0原文

我不确定我是否问了正确的问题。

我们有一个网络应用程序,我们正在尝试让第三方 POST 到该应用程序。我们正在为他们创建一个特殊的登陆页面,他们可以通过 POST 向其提交我们需要的数据。

我不确定如何响应他们的请求,我假设我将其作为传入的 HttpRequest 进行处理。我是否在 PageLoad 或其他事件中处理他们的数据?这些数据包含在哪里/如何?

我是否必须使用 HttpListener 或 ProcessRequest 处理程序,还是什么?

在这里或在 Google 上进行搜索会出现很多有关如何 POST 到另一个站点的结果,但似乎无法找到有关如何成为“其他”站点并处理传入 POST 数据的相关站点。

再说一遍,我不确定我问的是否正确。

编辑:我在中找到了 Page.ProcessRequest 方法MSDN 库<​​/a>,但备注说“您不应该调用此方法”

谢谢!

I'm not sure if I'm asking the right question.

We have a web app that we're trying to have a 3rd party POST to. We're creating a special landing page for them to which they can submit the data we need via POST.

I'm not sure how to respond to their request, which I assume I handle as an incoming HttpRequest. Do I process their data in PageLoad or some other event? Where/How is this data contained?

Do I have to use HttpListener or the ProcessRequest handler, or what?

Doing a search here or on Google turns up a lot of results on how to POST to another site, but can't seem to find a relevant site on how to be that "other" site and handle the incoming POST data.

Again, I'm not sure I'm asking this right.

EDIT: I found the Page.ProcessRequest Method in the MSDN library, but the Remarks say "You should not call this method"

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

吃不饱 2024-10-03 06:12:43

您确实需要了解 ASP.NET 的基础知识。即使在这种情况下 IHttpHandler 最适合,我也建议在这种情况下使用 .aspx 页面,因为它是开始学习的最佳位置,并且您可以稍后转向 IHttpHandler。

如果数据发布在 application/x-www-form-urlencoded 或 multipart/form-data (网页上表单使用的两种格式 - 如果他们没有告诉您他们正在使用什么格式,那么它可能是其中之一2),Request.Form 属性(实际上是属性的属性)将充当发送数据的字典(例如,如果它们有一个名为“foo”的字段,则 Request.Form 属性)将充当发送数据的字典。 Form["foo"] 将以字符串形式返回它的值)。否则,您将需要使用 Request.InputStream 并从中读取。不过,后者涉及的内容有点多。

You really need to look at the basics of ASP.NET. Even if this were a case where an IHttpHandler would be best-suited, I'd suggest using an .aspx page in this case as it's the best place to begin learning, and you can move to an IHttpHandler later on.

If the data is posted in application/x-www-form-urlencoded or multipart/form-data (the two formats used by forms on web pages - if they haven't told you what format they are using then it's probably one of those two), the Request.Form property (actually, a property of a property) will act as a dictionary into the data sent (e.g. if they have a field called "foo" then Request.Form["foo"] wll return the value of it as a string). Otherwise you'll want to use the Request.InputStream and read from that. This latter is a tiny bit more involved though.

会傲 2024-10-03 06:12:43

最好是使用 IHttpHandler,但它是可以使用标准 ASP.NET 页面执行您想要的操作。使用 PageLoad 就可以了,您可以访问 RequestResponse 属性,它们为您提供处理 HTTP 请求所需的一切。例如,要获取表单参数,您可以使用 Request["input1"] 来获取表单输入值(查询字符串、表单帖子或 cookie)命名为“输入1”。

您需要做什么来响应此帖子请求?您需要返回什么类型的数据?在得到答案之前,很难提供进一步的帮助。

Best would be to use an IHttpHandler, but it is possible to do what you want using a standard ASP.NET Page. Using PageLoad is fine, you have access to the Request and Response properties, which give you everything you need to process an HTTP request. For example, to obtain form parameters, you can use Request["input1"] to get the form input value (either query string, form post, or cookie) with the name "input1".

What is it you need to do in response to this post request? What sort of data do you need to return? Until that is answered, hard to help further.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文