在经典 ASP 中读取标头值时遇到问题 [英] having trouble reading header values in classic ASP

查看:13
本文介绍了在经典 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
%>

并且显示所有键,包括自定义键.但是没有一个自定义会.值是我需要的部分.

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天全站免登陆