无法在经典ASP中读取标头值 [英] having trouble reading header values in classic ASP

查看:72
本文介绍了无法在经典ASP中读取标头值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是所有内部服务器和软件,因此我的选择非常有限,但这就是我的工作范围.这已经是解决方法的一个创可贴,但是我别无选择,所以我只是想使其发挥作用.

This is all internal servers and software, so I'm very limited on my options, but this is where I'm at. This is already a band-aid to a workaround but I have no choice, so I'm just trying to make it work.

我的服务器上有一个简单的.asp文件,该文件受将处理用户身份验证的服务保护(我无法控制此服务).当用户转到此.asp文件时,它要求他们通过服务进行身份验证,然后该服务将其重定向到.asp.

I have a simple .asp file on my server that is protected by a service that will handle the user authentication (I have no control over this service). When a user goes to this .asp file, it requires them to authenticate via the service, and the service then redirects them to the .asp.

该服务正在将自定义值插入到http标头中,使我可以识别谁已登录(我需要在其后的位置进行登录).当我使用asp从标题查看ALL_RAW和ALL_HTTP值时,我可以看到所有自定义值.但是,当我尝试专门调用这些值时,我什么也没得到.

The service is inserting custom values in to the http header that allow me to identify who has logged in (I need it further down the line). When I use the asp to view the ALL_RAW and ALL_HTTP values from the header, I can see all the custom values. But when I try to call these values specifically I get nothing.

我运行了一个简单的循环:

I ran this simple loop:

<%
for each x in Request.ServerVariables
  response.write("<B>" & x & ":</b> " & Request.ServerVariables(x) & "<p />")
next
%>

,所有键均显示,包括自定义键.但是所有自定义 values 都不会.这些值是我需要的部分.

and all the keys display including the custom ones. But none of the custom values will. The values are the part I need.

关于定制值,我唯一能找到的独特之处是它们在ALL_RAW值中看起来略有不同,但是在ALL_HTTP中它们看起来都正确.据我所知,它们的格式正确.标准值和自定义值之间唯一的格式差异是大小写和下划线而不是连字符.

the only thing I can find unique about the custom values is that they look slightly different in the ALL_RAW value, but they all look correct in the ALL_HTTP. As best I can tell, they are formatted correctly. the only formatting differences between the standard and custom values are case and underscores instead of hyphens.

为什么我不能读取这些自定义值?

Why can I not read these custom values?

推荐答案

我找到了答案.

当我运行此循环

<%
for each x in Request.ServerVariables
  response.write("<B>" & x & ":</b> " & Request.ServerVariables(x) & "<p />")
next
%>

它将返回标题中所有名称及其值的列表.我一直在寻找的自定义值将显示为名称"HTTP_CUSTOM_ID",并且可以看到它,它的值位于ALL_HTTP和ALL_RAW中,但是当我尝试提取该特定值时,它将返回一个空字符串.我偶然发现的解决方案(通过与工作中遇到过类似情况的其他人交谈,而我曾尝试提供相同的服务)是使用

it would return a list of all the names that were in the header and their values. The custom value I was looking for would show as name "HTTP_CUSTOM_ID" and I could see it, with it's value in the ALL_HTTP and ALL_RAW, but when I tried to pull that specific value, it would return an empty string. The solution I stumbled on (by talking to someone else here at work who had gone through a similar situation with the same service I was trying to accommodate is to use:

<%=Request.ServerVariables("HEADER_CUSTOM_ID")%>

查看完整的标头时,没有什么使我使用HEADER前缀而不是HTTP,实际上,这使我反了.而且,我也从未在网上搜索到任何有关此的内容.因此,我将在此处发布自己的问题答案,以便将其发布在网络上.

When viewing the full header, nothing led me to use the HEADER prefix instead of the HTTP, in fact, it led me opposite. And I never found any mention of this anywhere searching online either. So I'm posting my own answer to my question here so it is on the web.

这篇关于无法在经典ASP中读取标头值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆