asp.net/html 中的表单集合是什么?
简单的问题,但我需要自己澄清一下。就可以在请求对象中访问的集合而言,有:
Cookies: (whats in a text file in the browser)
Querystring: (whats passed in the url like [key=value&key=value etc])
Server Variables: ?
Form Variables: ?
带有 ? 的集合。接下来是我不太明白它们在 http packet/html 中的位置的那些。我使用wireshark进行了捕获:
POST /Security/HelixSessionAuth.aspx HTTP/1.0
Content-Type: application/x-www-form-urlencoded
Content-Length: 391
ClientIP=192.168.20.31
Url=%2Fflash%2F56553550%5Fhi%2Emp4
Log=SESSIONSTART%20%5B13%2FDec%2F2010%3A16%3A31%3A23%20%2B0000%5D%20%20flash%2F56553550%5Fhi%2Emp4%200%20192%2E168%2E20%2E31%203%20%5B13%2FDec%2F2010%3A16%3A31%3A23%20%2B0000%5D%200%200%200%20%5B0%20No%20Error%5D%20%5B0%20No%20Error%5D%20%5Brtmp%3A%2F%2Fhelix%2Epete%2Evideolibraryserver%2Ecom%2Fflash%2F56553550%5Fhi%2Emp4%5D%0A
HTTP/1.1 404 Not Found
Content-Type: text/html; charset=us-ascii
Server: Microsoft-HTTPAPI/2.0
Date: Mon, 13 Dec 2010 16:31:23 GMT
Connection: close
Content-Length: 315
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/strict.dtd">
<HTML><HEAD><TITLE>Not Found</TITLE>
<META HTTP-EQUIV="Content-Type" Content="text/html; charset=us-ascii"></HEAD>
<BODY><h2>Not Found</h2>
<hr><p>HTTP Error 404. The requested resource is not found.</p>
</BODY></HTML>
它们会在上面的提要中的什么位置?
Simple question but one i need to clarify for myself. In terms of collections that can be accessed in the request object there is:
Cookies: (whats in a text file in the browser)
Querystring: (whats passed in the url like [key=value&key=value etc])
Server Variables: ?
Form Variables: ?
The ones with the ? next to are the ones that I dont really understand where in the http packet/html they are placed. I did a capture using wireshark:
POST /Security/HelixSessionAuth.aspx HTTP/1.0
Content-Type: application/x-www-form-urlencoded
Content-Length: 391
ClientIP=192.168.20.31
Url=%2Fflash%2F56553550%5Fhi%2Emp4
Log=SESSIONSTART%20%5B13%2FDec%2F2010%3A16%3A31%3A23%20%2B0000%5D%20%20flash%2F56553550%5Fhi%2Emp4%200%20192%2E168%2E20%2E31%203%20%5B13%2FDec%2F2010%3A16%3A31%3A23%20%2B0000%5D%200%200%200%20%5B0%20No%20Error%5D%20%5B0%20No%20Error%5D%20%5Brtmp%3A%2F%2Fhelix%2Epete%2Evideolibraryserver%2Ecom%2Fflash%2F56553550%5Fhi%2Emp4%5D%0A
HTTP/1.1 404 Not Found
Content-Type: text/html; charset=us-ascii
Server: Microsoft-HTTPAPI/2.0
Date: Mon, 13 Dec 2010 16:31:23 GMT
Connection: close
Content-Length: 315
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/strict.dtd">
<HTML><HEAD><TITLE>Not Found</TITLE>
<META HTTP-EQUIV="Content-Type" Content="text/html; charset=us-ascii"></HEAD>
<BODY><h2>Not Found</h2>
<hr><p>HTTP Error 404. The requested resource is not found.</p>
</BODY></HTML>
Where abouts would they be in the above feed?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
Form 集合是页面中通过 POST 方法传递到操作页面的控件列表。 Querystring 是 GET、POST 将项目添加到 Form 集合中。如果您知道 POST 中控件的名称,则可以使用以下方式在操作页面中访问其值:
在 .Net Web 表单中,这有点复杂,因为 .Net 注入专门的 ClientID 来保留实际控件的 ID在后面的代码中。
服务器集合是常见服务器变量的集合,用于标识有关客户端、服务器、连接、浏览器等的信息。可以在此处找到完整列表:
https://msdn.microsoft.com/en-us/library/ms524602(v=vs.90).aspx
The Form collection is the list of controls in the page that are passed to the action page via the POST method. Querystring is a GET, POST adds items to the Form collection. If you know the name of the control in the POST, you can access its value in the action page using:
In .Net web forms, this is a little more complicated because .Net injects a specialized ClientID to preserve the ID of the actual control in the code behind.
The server collection is a collection of common server variables identifying information about the client, server, connection, browser, etc. A full list can be found here:
https://msdn.microsoft.com/en-us/library/ms524602(v=vs.90).aspx
Wireshark 对此有点像大锤破解坚果,我建议从 HttpRequest 的 MSDN 文档。这应该可以帮助您理解表单和服务器集合是什么以及它们代表什么,然后您就会知道您在实际数据包中寻找什么。
Wireshark for this is a bit of a sledgehammer-to-crack-a-nut, I'd suggest starting with the MSDN documentation for HttpRequest. This should help you understand what the Form and Server collections are and what they represent, then you'll know what you are looking for in the actual data packet.
首先关于你的工具。
WireShark
是一个低级数据包分析工具,学习 HTTP 概念时不需要它。请改用 Fiddler。ServerVariables:
这是来自 asp classic 的旧对象。现在他们的对象有很多别名。例如,
Request.UserHostAddress
是Request.ServerVariables("remote_addr")
的别名。此外,
Headers
、Cookies
、Session
对象等都可以从此对象中获得。这个对象有更多的向后兼容性。表单变量:
ASP.NET 中的所有控件均由 ASP.NET 使用 ID 进行跟踪,并且它们的状态保存在
ViewState
隐藏字段中。视图状态是 ASP.NET 网页用来跨PostBacks
持久保存 Web 表单状态更改的技术。因此,在服务器端的每个
PostBack
(表单发布,即单击按钮)上,ASP.NET 都会从发布数据重新填充表单对象及其子对象(表单内的控件)。这就是我们所说的表单收集。First about your tool.
WireShark
is a low level packet analysis tool which you don't need for learning HTTP concepts. Instead use Fiddler.ServerVariables:
This is an old object from asp classic. Now there are many aliases for their objects. For example
Request.UserHostAddress
is an alias forRequest.ServerVariables("remote_addr")
.Also
Headers
,Cookies
,Session
objects, ... are available from this object. This object is there more of backward compatibility.Form Variables:
All controls in ASP.NET are tracked with an ID by ASP.NET and their state is hold within
ViewState
hidden field. view state, is the technique used by an ASP.NET Web page to persist changes to the state of a Web Form acrossPostBacks
.So, on every
PostBack
(form post, i.e click a button) ASP.NET at server side would repopulate form object and its children (controls inside the form) from post data. That's we call form collection.