如何迭代sys.net.webrequest(ajax)的头文件

时间:2022-10-13 14:01:51

How can I iterate over the headers in the sys.net.webrequest object. The documentation says it is a dictionary, but there seems not to be an easy way to iterate over the dictionary.

如何迭代sys.net.webrequest对象中的标头。文档说它是一本字典,但似乎没有一种简单的方法来迭代字典。

1 个解决方案

#1


0  

Without knowing what this sys.net.webrequest thing is (I'm not an ASP.Net Ajax guy), here's how you'd iterate over a dictionary anyway.

不知道这个sys.net.webrequest是什么东西(我不是一个ASP.Net Ajax的家伙),这里是你如何迭代字典。

var headers = MyWebRequest.get_headers();
for(var key in headers) {
    if(headers.hasOwnProperty(key) {
        // here key is the name of the header, and headers[key] is it's value
    }
}

#1


0  

Without knowing what this sys.net.webrequest thing is (I'm not an ASP.Net Ajax guy), here's how you'd iterate over a dictionary anyway.

不知道这个sys.net.webrequest是什么东西(我不是一个ASP.Net Ajax的家伙),这里是你如何迭代字典。

var headers = MyWebRequest.get_headers();
for(var key in headers) {
    if(headers.hasOwnProperty(key) {
        // here key is the name of the header, and headers[key] is it's value
    }
}