从 ASP.NET 中的另一个源获取字符串形式的发布数据
我有一个 URL,数据正在通过另一个供应商的 ERP 软件发布在该 URL 上......我想收集该供应商在页面加载事件中发布在我的 URL 上的数据......应该做什么在 ASP.NET 中使用 C# ? 他没有字段名称,而是自动生成数据字符串,然后将其自动发布到我的 ASP.NET 页面。
I have a URL and data is being posted on that URL through ERP software from another vendor.....I want to collect the data posted on my URL in page load event from that vendor....What should be done for that in ASP.NET with c#?
He does not have a field name and he is auto-generating the string of data and then posting it automatically to my ASP.NET page.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
首先,如果您知道要接收哪种数据,那么您应该添加:
然后在流读取器中读取该数据:
流读取器中的数据是 Url 编码的。所以你必须在进一步使用它之前对其进行解码:
仅此而已。我希望它有帮助。
First if you know what kind of data you're going to receive then you should add:
Then read that data in stream reader:
The data in streamreader is Url Encoded. So you've to decode it before you use that further:
That's all. I hope it helps.
请参阅 HttpRequest.QueryString
See HttpRequest.QueryString
我明白你说查询没有字段名称;这意味着您不能像普通的 QueryString 那样使用字符串索引器来查找它。如果是这样,那么您可能必须在不知道查询键的情况下访问它。
假设您知道“data”是第一个参数,您可以像这样访问它:
如果这不起作用,您可以直接访问 url
I understand you said that the Query doesn't have a field name; meaning you can't look for it like a normal QueryString, using the string indexer. If so, then you probably have to access it without knowing the query key.
assuming you know that the 'data' is the first parameter, you could access it like this:
If that won't work, you can access the url directly
如果他们正在执行 POST,您可以使用
Request.Form
。它将返回发布到 Url 的元素的NameValueCollection
,如果您不知道所发布内容的名称,则可以循环遍历它。如果您知道名称,则可以执行Request.Form["NamedItem"]
。If they are doing a POST, you can use
Request.Form
. It will return aNameValueCollection
of the elements posted to the Url, and you can loop through it if you don't know the name of what is being posted. If you know the name, then you can doRequest.Form["NamedItem"]
.将迭代 Request.Querystrung、Request.Form 和 Request.Params。
will iterate through Request.Querystrung, Request.Form, and Request.Params.